Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #define RESPONSE_SIZE 40
  2. #define FREQUENCY_SIZE 11
  3.  
  4.  
  5. int main()
  6. {
  7. int answer;
  8. int rating;
  9.  
  10. /* place survey responses in array responses */
  11. int frequency[ FREQUENCY_SIZE ] = { 0 };
  12.  
  13.  
  14. int responses[ RESPONSE_SIZE ] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10,
  15. 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6,
  16. 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 };
  17.  
  18. /*for each answer, select value of an element of array responses
  19. and use that value as subscript in array frequency to
  20. determine element to increment */
  21.  
  22. for ( answer = 0; answer < RESPONSE_SIZE; answer++ ) {
  23. ++frequency[ responses [ answer ] ]; // this part is complex for me, can you please explain it further?
  24. }
  25.  
  26.  
  27. printf( "%s%17sn", "Rating", "Frequency" );
  28.  
  29. /* output frequencies in tabular format */
  30. for ( rating = 1; rating < FREQUENCY_SIZE; rating++ ) {
  31. printf( "%6d%17dn", rating, frequency[ rating ] );
  32. }
  33. _sleep(1000*100);
  34.  
  35. return 0;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement