How to arrange a set of number?

Write a program to arrange given set of number in ascending order using link lists in c language?

  • Answer:

    #include <stdio.h> #include <conio.h> int main() { int a[10],i,j,temp=0; printf("Enter all the 10 numbers"); for(i=0;i<10;i++) scanf("%d",&a[i]); for(i=0;i<10;i++) //This loop is for total array elements (n) { for(j=0;j<9;j++) //this loop is for total combinations (n-1) { if(a[j]>a[j+1]) //if the first number is bigger then swap the two numbers { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("The ordered array is"); for(j=0;j<10;j++) //Finally print the ordered array printf("%d \t",a[j]); getch(); return 0; }

community wiki at wiki.answers.com Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.