C Program has so many wonderful features.It Can sort data.Here is the following code::
#include<stdio.h>
#include<conio.h>
void main()
{
int a[22],i,j,k;
clrscr();
for(i=1;i<=5;i++)
scanf("%d",a[i]);
for(i=1;i<=5;i++)
{
for(j=1;j<=5-i;j++)
{
if(a[j]>a[j+1])
{
k=a[j];
a[j]=a[j+1];
a[j+1]=k;
}
}
}
printf("\n\n\nThe output is:");
for(i=1;i<=5;i++)
printf("%4d",a[i]);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[22],i,j,k;
clrscr();
for(i=1;i<=5;i++)
scanf("%d",a[i]);
for(i=1;i<=5;i++)
{
for(j=1;j<=5-i;j++)
{
if(a[j]>a[j+1])
{
k=a[j];
a[j]=a[j+1];
a[j+1]=k;
}
}
}
printf("\n\n\nThe output is:");
for(i=1;i<=5;i++)
printf("%4d",a[i]);
getch();
}
No comments:
Post a Comment