🔒 Closed Pa help naman

Status
Not open for further replies.

cie1998

Established
Hello mga ka phc :)
pa help naman sa algorithm nito hehe received_1561872687291566.webp
 
kapag may loop po?

Code:
1) let n equals to total numbers to add
2) let t equals to sum
3) let a equals to average of all the numbers
4a) while n is > 0
4b) input a number
4c) add number to t
4c) n - 1
4d) end while
5) a is equals to t  divided by n

or (using while loop)

input total number to add
n = total numbers to count;
t = 0;
a = 0;
while n is > 0
   input a number
   t = t + input;
   n = n - 1;
end of while
a = t / n;
 
or (using for loop)

input total number to add
n = total numbers to count;
t = 0;
a = 0;

for 0 to n-1
   input a number
   t = t + input;
   n = n + 1;

a = t / n;

IN JAVA

int n = 0;
int t = 0;
int a = 0;
Scanner input = new Scanner(System.in);
n = input.nextInt();
while(n>0){
      int number = input.nextInt();
      t += number;
      n = n -1;
}
a = t / n;
System.out.println("Average is : " + a);
 
hahahaha wait lang po noob noob po ako pag dating sa programming ehh
hintay kanalan ng ibang comment

Sorry :)
ayuun madaming salamat po sa inyo :)

Code:
1) let n equals to total numbers to add
2) let t equals to sum
3) let a equals to average of all the numbers
4a) while n is > 0
4b) input a number
4c) add number to t
4c) n - 1
4d) end while
5) a is equals to t  divided by n

or (using while loop)

input total number to add
n = total numbers to count;
t = 0;
a = 0;
while n is > 0
   input a number
   t = t + input;
   n = n - 1;
end of while
a = t / n;
 
or (using for loop)

input total number to add
n = total numbers to count;
t = 0;
a = 0;

for 0 to n-1
   input a number
   t = t + input;
   n = n + 1;

a = t / n;

IN JAVA

int n = 0;
int t = 0;
int a = 0;
Scanner input = new Scanner(System.in);
n = input.nextInt();
while(n>0){
      int number = input.nextInt();
      t += number;
      n = n -1;
}
a = t / n;
System.out.println("Average is : " + a);
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 602
    Views
  • 3
    Participants
Last reply from:
cie1998

Trending Topics

Online now

Members online
1,158
Guests online
911
Total visitors
2,069

Forum statistics

Threads
2,279,313
Posts
28,989,778
Members
1,226,801
Latest member
ghoststitch
Back
Top