Skip to content

Instantly share code, notes, and snippets.

@anonur
Last active April 4, 2019 19:12
Show Gist options
  • Select an option

  • Save anonur/6428c7694c3c7ca6ea181d3fb9520c0d to your computer and use it in GitHub Desktop.

Select an option

Save anonur/6428c7694c3c7ca6ea181d3fb9520c0d to your computer and use it in GitHub Desktop.
Finds note average of 10 students
#include<stdio.h>
int main(void)
{
unsigned int counter;
int grade;
int total;
int average;
//initialization phase
total = 0; //initialize total
counter = 1; //initialize loop counter
//processing phase
while(counter <= 10) {
printf("%s","Enter grade: "); //prompt for input
scanf("%d",&grade); //read grade
total = total + grade; //add grade to total
counter = counter + 1; //increment counter
}//end while
//termination phase
average = total / 10; //integer division
printf("Class average is %d\n",average); //display result
} //end function main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment