Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


while loop problem

This problem is from a previous assignment that I only recieved partial credit on, and I want to know where I went wrong.

The task is, by using a while loop, to take 4 integers and sum up only those that are greater or equal to ten.

Here's what I had so far:


int main()
int counter;
int grade;
int total;

total = 0;
counter = 1;

while( counter <= 4 ) {
printf( "Enter an integer:
" );
scanf( "%d", &grade );

if ( grade >= 10 ) {

total = total + grade;
else {
total = total;

printf( "The total is %d
", total );

return 0;


Any help would be greatly appreciated! Thank you!
Sign In or Register to comment.