#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i=0,j=0,n;
clrscr();
printf("enter the number of elements");
scanf("%d",&n);
printf("enter the elements of list");
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-i-2;j++)
{
if(a[j]>a[j+1])
{
int temp;
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
printf("the sorted list is : ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
getche();
}
#include<conio.h>
void main()
{
int a[20],i=0,j=0,n;
clrscr();
printf("enter the number of elements");
scanf("%d",&n);
printf("enter the elements of list");
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-i-2;j++)
{
if(a[j]>a[j+1])
{
int temp;
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
printf("the sorted list is : ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
getche();
}
No comments:
Post a Comment