Compile and running a program Problem description: There are number of errors in
ID: 3759497 • Letter: C
Question
Compile and running a program
Problem description: There are number of errors in the following program, Correct /edit, Compile and run the program.
/****************************************************/
/* Name: */
/*Program description: Addition program */
/****************************************************/
#include <stdi0.h>
#define RESPONSE_SIZE 40 /* define array sizes */
#define FREQUENCY_SIZE 10
/* function main begins program execution
int main()
{
int answer; /* counter to loop through 45 responses */
int Rating; /* counter to loop through frequencies 1-10 */
/* initialize frequency counters to 0
int frequency[ FREQUENCY_SIZE ] = 0 };
/* place the survey responses in the responses array */
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, 2, 5, 6, 8, 9, 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_SISE; answer+=1);
{
+frequency[ responses [ answer ] ];
} /* end for */
/* display results */
printf( "%s%17s ", "Rating", "Frequency" );
/* output the frequencies in a tabular format */
for ( rating = 3; rating < FREQUENCY_SIZE; rating++ ) {
printf( "%6d%17d ", rating, frequency[ rating ] );
} /* end for */
return 0; /* indicates successful termination */
} /* end main */
Expected output:
Rating Frequency
1 2
2 3
3 2
4 2
5 6
6 12
7 5
8 8
9 2
10 3
Thank you using this program.
a) How many errors did you find in this program?
Copy sample of errors here
b) List all the Function prototype names, used in the program
Cut and paste the input here
c) What are the input statements?
Cut and paste the input here
d) Compile and run the program with the two numbers 74 and 4.
Cut and paste the output here
Explanation / Answer
Errors-
1.)In first for loop you have used wrong variable name instead of RESPONSE_SIZE you have used RESPONSE_SISE.
2.) You have defined RESPONSE SIZE as 40 but in array you have taken more than 40 integers.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.