Thursday, 2 May 2013

Sort the numbers in ascending order




#include<stdio.h>
void main()
{
    int a[10],i,j,temp;
    printf("Enter the marks of 10 students!!");
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<9;j++)
        {
            if(a[i]>a[j]){
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;}
        }

    }
    for(i=0;i<10;i++)
    printf(" %d   ",a[i]);

}

No comments:

Post a Comment