Arranging 5 Numbers in Ascending Order
code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,t;
clrscr();
printf("Enter 5 nos.\n\n");
for (i=0;i<5;i++)
scanf("%d",&a[i]);
for (i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("Ascending Order is:");
for(j=0;j<5;j++)
printf("\n%d",a[j]);
getch();
}
13 comments:
thanks, this is really use full for me
thanks a lot...
thank you ,your answer helped me a lot
pls explain for loop...
thnx a lot...realy wrkd!!
thank u...
thanks lot mate....saved my ass frm being fired
thank you it is used for my practical examination
thanks it help in chat in facebook
Thank you this is so useful :)
Thank you! You are great.
thanks... it is our topic in Semi Final Exam :)
NICE IT REALLY WORKED
Post a Comment