Code

darpan.kattel

Darpan Kattel

• Jan. 2, 2022, 7:24 p.m.

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

Question from IOE exam

C

#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;
}
Output:
Write a program to sort given 10 numbers in ascending order. | Output of C Language Code

Add comment:

Total 0 comments