Advertisement
yinnyboy333

order 3

Mar 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. //take and order 3 integers
  2.  
  3. #include <stdio.h>
  4.  
  5. int main(void) {
  6.  
  7. int num1, num2, num3;
  8.  
  9. printf("Enter integer: \n");
  10. scanf("%d", &num1);
  11.  
  12. printf("Enter integer: \n");
  13. scanf("%d", &num2);
  14.  
  15. printf("Enter integer: \n");
  16. scanf("%d", &num3);
  17.  
  18. printf("The numbers in order are: \n");
  19. // 123, 132
  20. if ((num1 <= num2) && (num1 <= num3)) {
  21. printf("%d ", num1);
  22. if (num2 <= num3) {
  23. printf("%d ", num2);
  24. printf("%d ", num3);
  25. } else {
  26. printf("%d ", num3);
  27. printf("%d ", num2);
  28. }
  29. }
  30. // 213, 312
  31. else if ((num2 <= num1) && (num3 <= num3)) {
  32. printf("%d ", num2);
  33. if (num1 <= num3) {
  34. printf("%d ", num1);
  35. printf("%d ", num3);
  36. } else {
  37. printf("%d ", num3);
  38. printf("%d ", num1);
  39. }
  40. // 312, 321
  41. } else {
  42. printf("%d ", num3);
  43. if (num1 <= num2) {
  44. printf("%d ", num1);
  45. printf("%d ", num2);
  46. } else {
  47. printf("%d ", num2);
  48. printf("%d ", num1);
  49. }
  50. }
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement