Answer to Question #84007 in C for nafi

Question #84007
Find the average, maximum, minimum, and sum of three numbers given by the user.
1
Expert's answer
2019-01-07T12:06:10-0500

#include<stdio.h>

int main()

{

int a, b, c;

int nMin, nMax, nSum;

printf("Enter 3 numbers separated by spaces: ");

scanf("%d %d %d", &a, &b, &c);


nMin = a;

nMax = a;

nSum = a + b + c;

/* minimum */

if (b < nMin)

{

nMin = b;

}

if (c < nMin)

{

nMin = c;

}

/* maximum */

if (b > nMax)

{

nMax = b;

}

if (c > nMax)

{

nMax = c;

}

printf("Max: %d\n", nMax);

printf("Min: %d\n", nMin);

printf("Sum of %d, %d and %d: %d\n", a, b, c, nSum);


return 0;

}

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
APPROVED BY CLIENTS