C Program to Sort Array Elements using Linear Sort
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// PROGRAM FOR SORTING OF ARRAY
#include<stdio.h>
#include<conio.h>
int main()
{
int ar[500],n,i,j,temp;
xyz:printf("\nEnter limit for array");
scanf("%d",&n);
if(n>500)
{
printf("\nInvalid limit pls enter between 1 to 500");
goto xyz;
}
printf("\nEnter elements in array");
for (i = 0; i <n ; i++)
scanf("%d",&ar[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(ar[j]<ar[i])
{
temp=ar[i];
ar[i]=ar[j];
ar[j]=temp;
}
}
}
printf("\nSorted elements of array:\n");
for (i = 0; i <n ; i++)
printf("%d\n",ar[i]);
return 0;
}
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

