🔒 Closed Pa help naman

Status
Not open for further replies.
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
  • 605
    Views
  • 3
    Participants
Last reply from:
cie1998

Trending Topics

Online now

Members online
1,090
Guests online
1,389
Total visitors
2,479

Forum statistics

Threads
2,292,999
Posts
29,080,675
Members
1,208,628
Latest member
Knowldee18
Back
Top