Write a programme which arrange three digit number in descending order? in C language

Let’s under stand some concept

If you enter three digit to arrange into descending order then you have to under stand the some concept of permutations and combination (according to permutations and combination). ” three digit number can arrange in six possible digit number” so, you have write six line for make number and six line to compare number to another.

Example– if you take number likes 123

Some sign are used like

  • () small bracket
  • && use for ‘and’ use for address
  • {} curly bracket
  • “” double code
  • #inclide<studio.h>
  • #include<conio.h>
  • void main()
  • {
  • Int var, a, b, c, d, e, f, g, h, I, j;
  • Clrscr();
  • Printf(“enter the three digit number to convert into ascending order” );
  • Scanf(“%d”, &var);
  • a=var/100;
  • b=var%100;
  • c=b/10;
  • d=b%10;
  • e=a*100+c*10+d;
  • f=c*100+a*10+d;
  • g=c*100+d*10+a;
  • h=d*100+c*10+a;
  • i=d*100+a*10+c;
  • j=a*100+d*10+c;
  • If(e<f&&e<g&&e<h&&e<i&&e<j)
  • {
  • printf(“smallest=%d”, e);
  • }
  • else if(f<e&&f<g&&f<h&&f<i&&f<j)
  • {
  • Printf(“smallest=%d”, f);
  • }
  • If(g<e&&g<f&&g<h&&g<i&&g<j)
  • {
  • printf(“smalllest=%d”,g);
  • }
  • else if(h<e&&h<f&&h<g&&h<i&&h<j)
  • {
  • printf(“smallest=%d”, h);
  • }
  • If(i<e&&i<f&&i<g&&i<h&&i<j)
  • {
  • Printf(“smallest=%d”,i);
  • }
  • else if(j<e&&j<f&&j<g&&j<h&&j<i)
  • {
  • printf(“smallest=%d”, j);
  • }
  • getch();
  • }

Input Output or result….

If you enter any number to arrange any number in descending order. Then result are given below.example 321

Results. 123

One Reply to “”

Leave a comment

Design a site like this with WordPress.com
Get started