fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b, c, temp;
  5.  
  6. // Prompt user for input
  7. printf("Enter three whole numbers: ");
  8. scanf("%d %d %d", &a, &b, &c);
  9.  
  10. // Sorting using if-else
  11. if (a < b) { temp = a; a = b; b = temp; }
  12. if (a < c) { temp = a; a = c; c = temp; }
  13. if (b < c) { temp = b; b = c; c = temp; }
  14.  
  15. // Print sorted numbers
  16. printf("Numbers in descending order: %d %d %d\n", a, b, c);
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5292KB
stdin
3 5 1
stdout
Enter three whole numbers: Numbers in descending order: 5 3 1