# include # include int iran ( int a, int b, int *seed ); int main ( ) { int a[10]; int b[10]; int count[10]; int i; int j; int n = 1000; int seed; int x[1000]; // // Set the array to random values between 0 and +100. // seed = time ( 0 ); for ( i = 0; i < n; i++ ) { x[i] = iran ( 0, 100, &seed ); } // // Set the counters to 0. // for ( j = 0; j < 10; j++ ) { count[j] = 0; } // // Define the limits. // for ( j = 0; j < 10; j++ ) { a[j] = j * 10; b[j] = ( j + 1 ) * 10; } // // Look at array entry I. // Is in inside interval J? // If so, up the count for interval J and go to the next array entry. // for ( i = 0; i < n; i++ ) { for ( j = 0; j < 10; j++ ) { if ( a[j] <= x[i] && x[i] <= b[j] ) { count[j] = count[j] + 1; break; } } } // // Print out the results. // printf ( "\n" ); printf ( "Number Greater than and Less than\n" ); printf ( "\n" ); for ( j = 0; j < 10; j++ ) { printf ( "%6i %6i %6i\n", count[j], a[j], b[j] ); } return 0; }