Code
Write a program to sort given 10 numbers in ascending order.
Question from IOE exam
Rate
#include
#include
int main()
{
int a[10],i,j,temp;
printf("Enter the 10 Numbers:");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Given numbers in ascending order:");
for(i=0;i<10;i++)
{
printf("\n%d",a[i]);
}
return 0;
}
Add comment:
Total 0 comments