Download .C file at the end of the post.
/* WAP to take 5 numbers from the user and sort it in ascending order and
print result. */
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,temp;
clrscr();
printf("\nEnter data one by one");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
//for sorting
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\nData arranged in ascending order");
for(i=0;i<5;i++)
{
printf("\t%d",a[i]);
}
getch();
}
Download .C file of above programme - CLICK HERE
0 comments:
Post a Comment