C examples for Array:Array Value
Using array to get 10 grades and then average them
#include <stdio.h> #define MAX_GRADE 100// w ww. j a va 2 s .c o m #define STUDENTS 10 int main( void ) { int grades[STUDENTS]; int total = 0; for(int idx=0;idx< STUDENTS;idx++){ printf( "Enter Person %d's grade: ", idx +1); scanf( "%d", &grades[idx] ); while ( grades[idx] > MAX_GRADE ) { printf( "\nThe highest grade possible is %d", MAX_GRADE ); printf( "\nEnter correct grade: " ); scanf( "%d", &grades[idx] ); } total += grades[idx]; } printf( "\n\nThe average score is %d\n", ( total / STUDENTS) ); return (0); }