Advertisement
Guest User

dawdadada

a guest
Feb 6th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define RESPONSE_SIZE 40
  4. #define FREQUENCY_SIZE 11
  5.  
  6. int main( void ) {
  7.  
  8.     int answer;
  9.     int rating;
  10.  
  11.     int frequency[ FREQUENCY_SIZE ] = {0};
  12.  
  13.     int responses[ RESPONSE_SIZE ] =  {1,2,6,4,8,5,9,7,8,10,
  14.                                        1,6,3,8,6,10,3,8,2,7,
  15.                                        6,5,7,6,8,6,7,5,6,6,
  16.                                        5,6,7,5,6,4,8,10,4,2};
  17.  
  18.     for ( answer = 0; answer < RESPONSE_SIZE; answer++) {
  19.         ++frequency[ responses [ answer ] ];
  20.     }
  21.  
  22.     printf("%s%17s\n", "Rating", "Frequency");
  23.  
  24.     for ( rating = 1; rating < FREQUENCY_SIZE; rating++ ) {
  25.         printf("%6d%17d\n", rating, frequency[rating]);
  26.     }
  27.  
  28.     return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement