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