# include int main ( ) { int g; int grade[100]; int i; int n; // // Read grades one by one. // // For "technical reasons", it's easier to use a temporary variable // G with SCANF, and then transfer that value into the GRADE array. // // We can't accept more than 100 grades because that's how much // space we set aside. // // If the user enters a "-1", we stop reading grades. // // To prove we know what is going on, once the user is done // entering data, we'll print it. // n = 0; printf ( "Enter grades one at a time, or -1 when done\n" ); while ( n < 100 ) { scanf ( "%i", &g ); if ( g == -1 ) { break; } grade[n] = g; n = n + 1; } // // Print the data. // printf ( "%d grades were entered.\n", n ); for ( i = 0; i < n; i++ ) { printf ( "%2i: %2i\n", i, grade[i] ); } return 0; }