how to make a program using while loop and the output is:

Status
Not open for further replies.
if this is in c or java (few differences, same idea)

int x, sum;

while(i<3)
{
printf("Enter a grade: ");
scanf(%d, x);
sum+=x;
i++;
}

printf("Average: %d", sum/3);



replace %d with %lf and initialize variables as a double if you aren't using whole number grades or don't want a whole number rounded average. Also if the number of grades isn't always 3, add another variable to count that and use total++; to make a total grades counter.
 
Homework assignments are generally not a good idea here, unless you show your previous work.

"I did A, B, and C. Here's the code. What am I missing? "

Closing this.
 
Status
Not open for further replies.