Question
Write a program that inputs up to 100 real numbers from the keyboard (one at a time). When a number greater than 1.0e9 is input the keyboard input will stop. Then the following statistic for the input data will be computed and printed out to the screen.
a) average
b) standard deviation
c) minimum value
d) maximum value
e) range = (maximum-minimum)/2
f) the number of times zero is input
**Note: this is a program in C++**

3) Write a program that inputs up to 100 real numbers from the keyboard (one at a time). When a number greater than 1.0e9 is
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include<iostream>
#include<cmath>

using namespace std;

int main()
{
float num,sum=0.0,average,sd=0.0;
float arr[100];

int count=0;
for(int i=0;i<=99;i++)
{
cout<<"Enter a real number: ";
cin>>num;
if(num>1.0e9) // 1.0e9 = 1000000000
{
break;
}
arr[i]=num;
sum=sum+num;
count++;
}
average=sum/count; //to get average

int zero=0;
float min=arr[0];
float max=arr[0];
for(int i=0;i<count;i++)
{
sd=sd+pow(arr[i]-average,2);//code for standard Deviation but without square root
  
if(min>arr[i]) //code for Minimum Value
{
min=arr[i];
}
if(max<arr[i]) //code for maximum value
{
max=arr[i];
}
if(arr[i]==0) // code for occurences of zero
{
zero++;
}
  
}

float range=(max-min)/2; // to get range

cout<<"\nAverage: "<<average<<endl;
cout<<"Standard Deviation: "<<sqrt(sd/count)<<endl; //to get Standard Deviation
cout<<"Minimum Value: "<<min<<endl;
cout<<"Maximum value: "<<max<<endl;
cout<<"Range: "<<range<<endl;
cout<<"The number of times zero is input: "<<zero<<endl;
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a program that inputs up to 100 real numbers from the keyboard (one at a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT