by CodeChum Admin
A descending order means values arranged from largest to smallest. But in your case, you're going to have to sort these integers in ascending order, which means from smallest to largest.
Instructions:
Input
1. First integer
2. Second integer
3. Third integer
Output
The first three lines will contain message prompts to input the 3 integers.
The last line contains the three integers in ascending order.
TEST CASES
Enter the first integer: 6
Enter the second integer: 1
Enter the third integer: 3
1 3 6
Enter the first integer: 6
Enter the second integer: 4
Enter the third integer: 2
2 4 6
Enter the first integer: 0
Enter the second integer: 2
Enter the third integer: 0
0 0 2
Enter the first integer: 1
Enter the second integer: 1
Enter the third integer: 1
1 1 1
#include <stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
int main(){
int a, b, c,minNumber,maxNumber;
printf("Enter the first integer: ");
scanf("%d", &a);
printf("Enter the second integer: ");
scanf("%d", &b);
printf("Enter the third integer: ");
scanf("%d", &c);
minNumber = min(min(a, b), c);
maxNumber = max(max(a, b), c);
printf("%d %d %d\n", minNumber,(a+b+c-minNumber-maxNumber),maxNumber);
getchar();
getchar();
return 1;
}
Comments
Leave a comment