+ 1
To find the average height of a group of students using for statement
4 Respostas
+ 6
Is this a homework.
Make a for loop with two variables height and number.
Declare how many times you have to take input as statement. each time add it to height and increment number.
Declare a variable which will be height/number.
For example, you have to take heights of five students.You can do it like this.
int height, number.
for(int i = 0; i < 5;i++ ){
int c;
cin >> c;
height += c;
number++;
}
average = height/number;
cout << average.
+ 1
please give the answer as a program
+ 1
Beenu Thomas Have you tried it yourself.
+ 1
Yes. I got the answer