help me please?
Write a program that uses a for statement to calculate and print the average of several integers. Assume the last value read is the sentinel 9999. A typical input sequence might be
10 8 11 7 9 9999indicating that the program should calculate the average of all the values preceding 9999.

// program for statement
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main(){
//declaration of variables
int i=0,
next;
int count = 1;// count =1 so that it sets the end point in the for statement
double sum=0,
average;

cout<<"\nEnter 9999 when you are done with input\n ";

for(i=0; i<count; i++){
cout<<"\nEnter the next Element: ";
cin>>next;
if(!(next==9999)){
count += 1;// count increases with the validity of the input
sum += next;}else{
average = sum/(count-1); // (count -1) serves remove the initializer 1
cout<<"\nThe average is ==> "<<average<<endl<<endl;
}
}
return 0;
}

OK, now that you've done his homework for him, will you get the grade for the program? :rolleyes: You both need to read this, and this

what do you mean grade, i am new on the site:-|

what do you mean grade, i am new on the site:-|

Will you get the A on his assignment? Or more to the point, using your answer, does he deserve the grade he gets?

IOW, we would prefer to help the poster find the answer, not do his homework for him.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.