Sorting An Array

Accept 10 numbers and store in an array, print sorted array in descending and ascending order:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,temp;
clrscr();
printf("Enter 10 nos\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[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<10;i++)

 printf(" %d ",a[i]);
 printf(" Nos sorted in ascending order\n");
 printf("\n");
 for(i=9;i>=0;i--)
printf(" %d ",a[i]);
printf(" Nos sorted in descending order\n");
getch();
}

17 comments:

  1. Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

    ReplyDelete
  2. Hi, Nice Program for Sorting An Array.Thanks, its really helped me......

    -Aparna
    Theosoft

    ReplyDelete
  3. MERGE SORT, BUBBLE SORT, HEAP SORT, INSERTION SORT, QUICK SORT and other types of sorting at :

    http://thec-language.blogspot.in/p/blog-page_23.html

    ReplyDelete
  4. Best C Programs with Complete Explanation ..
    Visit To Code ►► Lightning Code

    ReplyDelete
  5. Thanks for your ideas. You can also find the details on Affity Solutions, at the C++ Developers. The main object of the Affity Solutions is to provide quality web services and is among the few software development company in Nagpur.

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

    ReplyDelete
  7. C tutorial with free and simple example on Data Types & Variables, Conditionals, Loops, Arrays & Strings etc. Here you can download simple and easy online c tutorial for beginners .C Programming online test.

    ReplyDelete
  8. Good
    Here is a link for C/C++ programs and pointer programs. This may be useful for you.

    C Programs

    C++ Programs

    ReplyDelete
  9. Go on cproinfo.blogspot.com
    For all programs,interview questions and examples

    ReplyDelete
  10. To know the programming technique: "Make Your Program Trial Version in C" visit:
    udebayan.blogspot.com

    ReplyDelete
  11. To know the programming technique: "Make Your Program Trial Version in C" visit:
    udebayan.blogspot.com

    ReplyDelete
  12. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete

  13. This blog is awesome,thanks for ur valuable inforamtion ,u want more inforamtion about C programming languages join C programming classes in bangalore,visit : Aptech computer education,my tage are :

    C training bangalore,C courses bangalore,C classes bangalore,C institute bangalore,C coaching centers bangalore,C programming institute in bangalore,C programming classes in bangalore

    ReplyDelete
  14. thanks for creating a nice post on c programming but did you know what is loop in c programming

    ReplyDelete
  15. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete

Related Post

Array:
String functions:
General (Loops-for/while)
Write a Program to print reverse of a given number Write a Program to print Product of Digits (eg. 212=2*1*2=4) of a given number Write a C++ Program to Convert Binary into Decimal Number