Skip to main content

Program to accept three numbers from user and print them in ascending and decending order.

 Program to accept three numbers from user and print them in ascending and decending order.


CODE

๐Ÿ‘‡

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.   int a,b,c;
  6.   printf("Enter numbers:");
  7.   scanf("%d %d %d",&a,&b,&c);

  8.   if ((a>=b)&&(a>=c)) 
  9.   {
  10.     if (b>=c) 
  11. {
  12.       printf("\nDesc : %d %d %d",a,b,c);
  13.       printf("\nAsc : %d %d %d",c,b,a);
  14.     } else 
  15. {
  16.       printf("\nDesc : %d %d %d",a,c,b);
  17.       printf("\nAsc : %d %d %d",b,c,a);
  18.     }
  19.   } else if ((b>=a)&&(b>=c)) 
  20.   {
  21.      if (a>=c) 
  22. {
  23.         printf("\nDesc : %d %d %d",b,a,c);
  24.      }
  25.   } else 
  26.   {
  27.     if (b>=a) 
  28. {
  29.       printf("\nDesc : %d %d %d",c,b,a);
  30.       printf("\nAsc : %d %d %d",a,b,c);
  31.     } else 
  32. {
  33.       printf("\nDesc : %d %d %d",c,a,b);
  34.       printf("\nAsc : %d %d %d",b,a,c);
  35.     }
  36.   }
  37. }


๐Ÿ‘‰Execute๐Ÿ‘ˆ

//OUTPUT
/*

*/




                                                                          //ThE ProFessoR