February 15, 2011

C Program to Arrange 5 Numbers in Ascending Order using Array


Arranging  5 Numbers in Ascending Order


code:

//C program for Arranging  5 Numbers in Ascending Order
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,t;
clrscr();
printf("Enter 5 nos.\n\n");
for (i=0;i<5;i++)
scanf("%d",&a[i]);
for (i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("Ascending Order is:");
for(j=0;j<5;j++)
printf("\n%d",a[j]);
getch();
}

Hope you liked the posts, give comments if you have any doubts.. :)

Related Posts :



Categories: ,

13 comments:

thanks, this is really use full for me

thank you ,your answer helped me a lot

thanks lot mate....saved my ass frm being fired

thank you it is used for my practical examination

thanks it help in chat in facebook

Thank you this is so useful :)

thanks... it is our topic in Semi Final Exam :)

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails