Sort an integer array in ascending order
Category : Simple Stuff
Sort an integer array in ascending order
Sort an integer array in ascending order
#include
#include
void main(void)
{
int n;//holds the total no. of vals.
int a[100];//Holds the numbers to be sorted
int i,i2,i3,temp,z;//i,i2,i3 & z are loop counters
clrscr();
printf ("Enter the no. of values you want to enter(100 max)>");
scanf ("%d",&n);
for (i=0;ia[i3+1])
{
temp=a[i3];//temp is used to swap a[i3] and a[i3+1]
a[i3]=a[i3+1];
a[i3+1]=temp;
}
clrscr();//this part prints the sorted array.
printf ("Printing sorted array\n");
for (z=0;z
