Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a c language program: Above main create a define as follows: #define ARRA

ID: 3593634 • Letter: C

Question

Create a c language program:

Above main create a define as follows:
#define ARRAY_SIZE 10

Right below the define, but above main, declare an integer array as follows:
int data[ARRAY_SIZE];

In main, use a for loop. Inside of the for loop, as the user for a number, and then place it into the correct array element (You must use a define in the loop). The following is a run of this loop:
Enter number 1: 14
Enter number 2: 44
Enter number 3: 33
Enter number 4: 99
Enter number 5: 84
Enter number 6: 15
Enter number 7: 1
Enter number 8: 7
Enter number 9: 189
Enter number 10: 42

Next, show the contents of the array as follows (you must use the define in the loop):

Number 1 is 14
Number 2 is 44
Number 3 is 33
Number 4 is 99
Number 5 is 84
Number 6 is 15
Number 7 is 1
Number 8 is 7
Number 9 is 189
Number 10 is 42

Finally, show what the average of all numbers is.

Explanation / Answer

#include<stdio.h>

#define ARRAY_SIZE 10

int data[ARRAY_SIZE];

int main()

{

/* i to iterate over the array and count to add the elements of the array */

int i=0,count=0;

for( i =0 ;i<ARRAY_SIZE;i++)

{

printf(" Enter number:");

scanf("%d",&data[i]); /* scanning the data */

}

for( i=0; i<ARRAY_SIZE; i++)

{

printf(" Number %d is %d",i+1,data[i]); /* printing all the numbers in array*/

count = count + data[i];

}

printf(" The average of the numbers entered :%d ",(count/ARRAY_SIZE)); /* printing the average */

return 0;

}

/* if any queries please comment */

/* thank you */