C examples for Array:Array Element
Use Array to track Counters
#include <stdio.h> int main (void) { int ratingCounters[11], response; for (int i = 1; i <= 10; ++i) ratingCounters[i] = 0;//from w ww . j a v a 2s.co m printf ("Enter number:"); for (int i = 1; i <= 20; ++i) { scanf ("%i", &response); if (response < 1 || response > 10) printf ("Bad response: %i\n", response); else ++ratingCounters[response]; } for (int i = 1; i <= 10; ++i) printf ("%4i%14i\n", i, ratingCounters[i]); return 0; }