0
64kviews
Write a program to sort given 10 numbers in ascending order.

Mumbai University> FE > Sem 2> STRUCTURED PROGRAMMING APPROACH

Marks: 10 M

Year: Dec 2016

1 Answer
1
5.3kviews
#include<stdio.h>
#include<conio.h>
main()
{
int a[10],i,j,temp;
printf(“Enter the 10 Numbers:”);
for(i=0;i<10;i++)
{
    printf(“Enter a value:”);
    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]);
}
getch();
}

Output:
Enter the 10 Numbers:
Enter a value: 12
Enter a value:20
Enter a value:7
Enter a value:44
Enter a value:56
Enter a value:5
Enter a value:34
Enter a value:22
Enter a value:17
Enter a value:50
Given numbers in ascending order:
5
7
12
17
20
22
34
44
50
56
Please log in to add an answer.