2/*Write a’ c’ program to accept ‘n’ numbers from user store these numbers into an array and sort the numbers of an array*/


#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],i,j,temp,limit;
clrscr();
printf(“\n Enter the numbers:”);
scanf(“%d”,&limit);
printf(“\n Enter %d elements\n”,limit);
for(i=0;i<limit;i++)
{
scanf(“%d”,&a[i]);
}
for(i=0;i<limit;i++)
{
for(j=i+1;j<limit;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf(“\n Sorted array is:\n”);
for(i=0;i<limit;i++)
printf(“\t %d”,a[i]);
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s