Hi there I have come accross some C code that I would like to be explained in very simple terms hope somebody can help me.
[code=c]
#include <stdio.h>
#define response_size 10
#define frequency_size 11
int main()
{
int answer;
int rating;
int frequency[frequency_size] = {0};
int responses[response_size] = {1,2,6,4,8,5,9, 7,8,10};
for(answer=0; answer<response _size; answer++)
{
++frequency[responses[answer]];
}
printf("%s%17s\ n","Rating ,"Frequency" );
for(rating =1; raring <frequency_sixe ;rating ++)
{
printf("%6d%17d \n",rating,freq uency[rating]);
}
}
[/code]
10 students were asked to rate the food in a canteen on a scale of 1-10 where 1 is awful and 10 is excellent, Place the 10 responses in an integer array and summarize the result of the poll, count how many 1's 2's etc etc
This piece of code "++frequenc y[responses[answer]];" is what i dont understand could someone please help
}
[code=c]
#include <stdio.h>
#define response_size 10
#define frequency_size 11
int main()
{
int answer;
int rating;
int frequency[frequency_size] = {0};
int responses[response_size] = {1,2,6,4,8,5,9, 7,8,10};
for(answer=0; answer<response _size; answer++)
{
++frequency[responses[answer]];
}
printf("%s%17s\ n","Rating ,"Frequency" );
for(rating =1; raring <frequency_sixe ;rating ++)
{
printf("%6d%17d \n",rating,freq uency[rating]);
}
}
[/code]
10 students were asked to rate the food in a canteen on a scale of 1-10 where 1 is awful and 10 is excellent, Place the 10 responses in an integer array and summarize the result of the poll, count how many 1's 2's etc etc
This piece of code "++frequenc y[responses[answer]];" is what i dont understand could someone please help
}
Comment