To use arrays. 2) To use iterative control statements in C. 3) Develop algorithm
ID: 3678012 • Letter: T
Question
To use arrays. 2) To use iterative control statements in C. 3) Develop algorithms to compute statistics Tasks: Background information: 1) Read "C How To Program": Chapter 6 (Sections 1 to 10) Programming assignment: 2) Write a program that prompts the user for a variable number of real numbers and computes several descriptive statistics on that set of real numbers. The real numbers should be placed in an array. 3) The specific descriptive statistics you should compute are: minimum, maximum, average and standard deviation. 4) Your program should adhere to the following I/O specifications: How many real numbers do yon wish to enter (maximum is 20): Read number from user Enter number 1: Enter number 2:... ... Minimum: ww.ww Maximum: xx.xx Average: yy.yy Standard Deviation: zz.zz 5) When printing floating point values, only print the first 2 decimal places 6) This is a sample output of your program How many real number do you wish to enter (maximum is 20): 5 Enter number 1: 5.0 Enter number 2: 4.0 Enter number 3: 5.0 Enter number 4: 0.0 Enter number 5: 6.0 maximum: 0.00 Maximum: 6.00 Average: 4.00 Standard Deviation: 2.10 Report: 7) Write a brief report (no cover page) with the format as follows a. Introduction - describe the assignment in your own words. b. Solution Model describe your solution, what steps did you follow? (you can use a flow chart to illustrate your procedure). What assumptions did you make?Explanation / Answer
#include <stdio.h>
int main(void) {
int limit;
float avg,sd,count=0.0,sdcount=0.0;
float max;
float min;
printf("How many real numbers do you wish to enter (Maximum is 20):");
scanf("%d",&limit);
printf(" ");
float values[20];
int i,j,k,l,m;
for(i=0;i<limit;i++)
{
printf("Enter number %d",i);
scanf("%f",&values[i]);
}
min=values[0];
for(j=1;j<limit;j++)
{
if(values[j]<min)
{
min=values[j];
}
}
printf("Minimum: %.2f",min);
max=values[0];
for(k=0;k<limit;k++)
{
if(max<values[k])
{
max=values[k];
}
}
printf("Maximum: %.2f",values[0]);
for(l=0;l<limit;l++)
{
count=count+values[l];
}
avg=count/limit;
printf("Average: %.2f",avg);
for(m=0;m<limit;m++)
{
sdcount=sdcount+(values[m]-avg)*(values[m]-avg);
}
sd=sdcount/limit;
printf("Standard deviation: %.2f",sd);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.