#include<stdio.h>
#include<conio.h>
void main()
{
int
a[50],i,n,temp,j;
clrscr();
printf("enter the size of
array:");
scanf("%d",&n);
printf("enter the
number:");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("array before
sorting:");
for(i=0;i<n;i++)
{
printf("\n%d",a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\narray after
sorting:");
for(i=0;i<n;i++)
{
printf("\n%d",a[i]);
}
getch();
No comments:
Post a Comment