Answer to Question #84004 in C++ for chuchu

Question #84004
Find the average, maximum, minimum, and sum of three numbers given by the user.
1
Expert's answer
2019-01-04T04:44:47-0500

#include <iostream>


using namespace std;


int main()

{

double m[3]{}, *p = m, i, min, max, sum = 0;

double average;

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

{

cout << "Enter number " << i + 1 << ':';

cin >> *p;

sum += *p++;

}

for (p = m, min = max = *p++, i = 1; i < 3; ++i, ++p)

{

if (*p > max)

max = *p;

if (*p < min)

min = *p;

}

average = sum / 3;

cout << "Sum = " << sum << endl

<< "Min = " << min << endl

<< "Max = " << max << endl

<< "Average = " << average << endl;

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS