OCJP

Ascending Digits Using C Language

#include<stdio.h>
#include<conio.h>
void main()
{
int n[10];
int i,j,k;
clrscr();
     printf("\nEnter the digits");
     for(i=0;i<10;i++)
     {
     printf("\nEnter NO:");
     scanf("\n%d",&n[i]);
     }
      for(i=0;i<10;i++)
      {
	 for(j=i+1;j<10;j++)
	 {
	 if(n[i]>n[j])
	    {
	    k=n[i];
	    n[i]=n[j];
	    n[j]=k;

	 }
	  }
      }
     for(i=0;i<10;i++)
     {
     printf("\nDigits n[%d] is %d",i,n[i]);
     }

getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?