Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help fixing my C++ program, the mean is wrong.... it needs to say The median of (3, 9, 5) is 5. The mean of

Need help fixing my C++ program, the mean is wrong.... it needs to say

The median of (3, 9, 5) is 5. The mean of (4, 5, 8, 20, 25) is 12.40

What I have

image text in transcribed

image text in transcribedimage text in transcribed

3 9 5 4 5 8 20 25 -1 The median of (3, 9, 5) is 5. The mean of (4, 5, 8, 20, 25) is 14.00. '1 #include 2 using namespace std; 4. int main() { '6 int count = 0; '7 int total = 0; 8 int x, y, z, a, median; double avg; 10 11 scanf("%i%i%i", ex, &y, &z); //scan for the first three integers 12 if((y > x && x > z)||(z > x && X > y)) 13 14 15 16 median = x; 17 else if((x > y && y > Z)||(z > y && y > x)) 18 - 19 median = y; 20 21 else 22 23 median = z; 24 median = z; 25 26 27 printf("The median of (%i, %i, %i) is %i. ", x, y, z, median); scanf("%i",&a); 28 printf("The mean of %i", a); 29_scanf("%i", &a); 30 31 while(a! =-1) // Creating the Mean 32-{ 33 total = total + a; count = count + 1; printf(", %i", a);//Print rest of integers scanf("%i", &a); 34 36 37 39 avg = total/count; 40 41 printf(") is %0.21f. ", avg); 42 43 } 44

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

Students also viewed these Databases questions