Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RESPONSE_SIZE 40
- #define FREQUENCY_SIZE 11
- int main()
- {
- int answer;
- int rating;
- /* place survey responses in array responses */
- int frequency[ FREQUENCY_SIZE ] = { 0 };
- int responses[ RESPONSE_SIZE ] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10,
- 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6,
- 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 };
- /*for each answer, select value of an element of array responses
- and use that value as subscript in array frequency to
- determine element to increment */
- for ( answer = 0; answer < RESPONSE_SIZE; answer++ ) {
- ++frequency[ responses [ answer ] ]; // this part is complex for me, can you please explain it further?
- }
- printf( "%s%17sn", "Rating", "Frequency" );
- /* output frequencies in tabular format */
- for ( rating = 1; rating < FREQUENCY_SIZE; rating++ ) {
- printf( "%6d%17dn", rating, frequency[ rating ] );
- }
- _sleep(1000*100);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment