64 506
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #16507 in C++ for zaima

Question #16507
write a program which inputs five numbers and displays
1. the minimum number
2. the maximum number
3. average of numbers
4. average of minimum and maximum numbers
5. difference between average and average of minimum and maximum numbers

sample output:

enter five numbers: 45 43 23 21 56
minimum number is: 21
maximum number is: 56
average of minimum and maximum numbers: 38.5
difference between average and average of minimum and maximum numbers: 0.9
Expert's answer
#include "iostream"
using namespace std;

short i;
float a[5], min, max, avm, ave=0;

void main(){
cout<<"enter five numbers: ";
cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
min = max = a[0];
for (i=1;i<5;i++){
& if (min>a[i]) min = a[i];
& if (max<a[i]) max = a[i];
& ave += a[i];
}
cout<<"minimum number is: "<<min<<"\n";
cout<<"maximum number is: "<<max<<"\n";
avm = (max+min)/2;
cout<<"average of minimum and maximum numbers: "<<avm<<"\n";
cout<<"difference between average and average of minimum and maximum numbers: "<<abs(ave/5-avm)<<"\n";
system("PAUSE");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions