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

Write it in c Here is the goal: read some numbers into an array, calculate the m

ID: 3678242 • Letter: W

Question

Write it in c Here is the goal: read some numbers into an array, calculate the mean (average), and write it out. 1. Put in some code so that a header is printed out with the project and your name, something like: Lab: Week 09. Programmer: Clyde the C-Programmer. Date: October 20, 2014. Get in the habit of always starting a code file with a header. Choose some sire SIZE big enough, say 100. to hold as many values as you expect to enter. Write this: const int SIZE - 100; Now declare an array of double named data of sire SIZE, and an int named numUsed, like this: double data (SIZE); int numUsed; Ask the user for number numUsed of values to enter. "Asking for" means: Prompt the user to enter the number, with enough information so she/he understands what you want. Read in the answer with scanf. Check that numUsed

Explanation / Answer

#include<stdio.h>

int main(){
  
   const int SIZE = 100;
   double data[SIZE];
   int numUsed;
   int i;
  
   printf("Enter a number in range of 0-100: ");
   scanf("%d",&numUsed);
  
   for(i=0; i<numUsed; ++i){
       printf(" Enter array element data[%d]: ",i);
       scanf("%lf",&data[i]);
       }
      
   double sum = 0;
   for(i=0; i<numUsed; i++){
       sum += data[i];
       }
   double mean = sum/numUsed;
  
   printf(" Mean value of numbers in array data is %.2lf. ",mean);
   return 0;
   }


/*

Output:

Enter a number in range of 0-100: 5

Enter array element data[0]: 12.43

Enter array element data[1]: 14.5

Enter array element data[2]: 15.43

Enter array element data[3]: 10.99

Enter array element data[4]: 21

Mean value of numbers in array data is 14.87.

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote