#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,n,j,temp;
clrscr();
printf("How many numbers you want to insert?\n");
scanf("%d",&n);
printf("Enter the numbers::\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("After Sorting-------\n");
for(i=0;i<n;i++)
printf("%d ",a[i]);
getch();
}
#include<conio.h>
void main()
{
int a[20],i,n,j,temp;
clrscr();
printf("How many numbers you want to insert?\n");
scanf("%d",&n);
printf("Enter the numbers::\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("After Sorting-------\n");
for(i=0;i<n;i++)
printf("%d ",a[i]);
getch();
}
No comments:
Post a Comment