Pages

Write a program to get numbers from user and sort is print on screen

Saturday, 4 May 2013

#include <stdio.h>
#include <conio.h>
int main()
{
    int a[10], i, temp;
    printf("Enter Numbers to sort: ");
    for(i=0; i<=9; i++)
    {
         scanf("%d", &a[i]);   
    }
    for(i=0; i<=9; i++)
    {
             if(a[i+1]<a[i])
             {
                    temp=a[i];
                    a[i]=a[i+1];
                    a[i+1]=temp;
                    i=-1;
             }
    }
   

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

Search Box

Most Reading

Contact Form

Name

Email *

Message *