//this is a program for sorting of an array elements
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,temp;
printf("\n\nAccepting the elements of array: ");
for(i=0;i<10;i++)
{
printf("\n\nEnter any number: ");
scanf("%d",&a[i]);
}
printf("\n\nDisplaying the elements of array of before starting: ");
for(i=0;i<10;i++)
printf(" %d ",a[i]);
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
{
if(a[j]<a[i])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\n\nDisplaying the array after sorting: ");
for(i=0;i<10;i++)
{
printf(" %d ",a[i]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,j,temp;
printf("\n\nAccepting the elements of array: ");
for(i=0;i<10;i++)
{
printf("\n\nEnter any number: ");
scanf("%d",&a[i]);
}
printf("\n\nDisplaying the elements of array of before starting: ");
for(i=0;i<10;i++)
printf(" %d ",a[i]);
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
{
if(a[j]<a[i])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\n\nDisplaying the array after sorting: ");
for(i=0;i<10;i++)
{
printf(" %d ",a[i]);
}
getch();
}