Wednesday, December 25, 2013

write a C Program to arrange 10 numbers in ascending order

C Program to arrange 10 numbers in ascending order





/*C Program to arrange 10 numbers in ascending order*/


#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,temp,a[10];

clrscr();

printf(Enter 10 integer numbers: \n);

for(i=0;i<10;i++)

scanf(%d,&a[i]);

for (i=0;i<10;i++)

{

for(j=i+1;j<10;j++)

{

if(a[i]>a[j])

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

}

printf(“\n\nThe 10 numbers sorted in ascending order are: \n);

for(i=0;i<10;i++)

printf(%d\t,a[i]);

getch();

}




OUTPUT:


Enter 10 integer numbers:

2

9

7

4

3

6

8

1

5

10

The 7 numbers sorted in ascending order are:

1     2       3       4       5            6       7       8       9      10





------------------------------------------------
Answers questions like


   
Write a c program to sort 10 numbers in ascending order
Write a program to arrange a list of numbers in ascending order
How to write a program for arranging numbers in ascending order
Write a c program to arrange numbers in ascending order
C++ Arrange 10 random integers in descending order? 
Write a C program to sort a string in ascending order.?
Program to sort numbers in ascending order and use integer point
Sort 10 Numbers In Ascending Order - C And C++
Write a simple program in java to accept 10 number

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include
    #include
    void main()
    {
    int a[10],i,j,t;
    clrscr();
    printf("Please enter thye number\n");
    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])
    {
    t=a[i];
    a[i]=a[j];
    a[j]=t;
    }
    }
    }
    printf("Shortest list are as follows\n");
    for(i=0;i<10;i++)
    printf("%d\n",a[i]);
    {
    getch();
    }
    }

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. include

    #include

    void main()

    {

    int i,j,temp,a[10];

    clrscr();

    printf(“Enter 10 integer numbers: \n”);

    for(i=0;i<10;i++)

    scanf(“%d”,&a[i]);

    for (i=0;i<10;i++)

    {

    for(j=i+1;j<10;j++)

    {

    if(a[i]>a[j])

    {

    temp=a[j];

    a[j]=a[i];

    a[i]=temp;

    }

    }

    }

    printf(“\n\nThe 10 numbers sorted in ascending order are: \n”);

    for(i=0;i<10;i++)

    printf(“%d\t”,a[i]);

    getch();

    }

    ReplyDelete
  5. #include
    #include
    main()
    {
    int i,j,temp,a[10];
    printf("Enter 10 numbers:");
    for(i=0;i<10;i++)
    scanf("%d",&a[i]);
    for (i=0;i<10;i++)
    {
    for(j=i+1;j<10;j++)
    {
    if(a[i]>a[j])
    {
    temp=a[j];
    a[j]=a[i];
    a[i]=temp;
    }
    }
    }
    printf("\nThe ascending order of the numbers are:\n");
    for(i=0;i<10;i++)
    printf("%d\n",a[i]);
    getch();
    }

    ReplyDelete