#include<stdio.h>
int main()
{
int a[' '],b,c,p,lim ;
printf("enter the size of your linner arrey - ");
scanf("%d",&b);
for(c=1;c<=b;c++)
{
printf("enter a value in a[%d] - ",c);
scanf("%d",&a[c]);
}
printf("The arrey entered by you is :\n");
for(c=1;c<=b;c++)
{
printf("%5d",a[c]);
}
for(lim=b;lim>0;lim--)
{
for(p=1;p<=lim-1;p++)
{
if(a[p]>a[p+1])
{
a[p]=a[p]+a[p+1];
a[p+1]=a[p]-a[p+1];
a[p]=a[p]-a[p+1];
}
}
}
printf("\nafter shorting your arrey in assending order\n");
for(c=1;c<=b;c++)
{
printf("%5d",a[c]);
}
}
Comments