Answer to Question #277489 in C for asd

Question #277489

Sort It Yourself

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:

  1. Input three integers.
  2. Print the integers in ascending order using your knowledge on conditional statements.

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
1
Expert's answer
2021-12-09T01:23:49-0500
#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;
}  

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