Write a program that sort an array of integers.
#include<conio.h>
#include<stdio.h>
void main()
{
int num[20],total_element,range,i,j,temp;
clrscr();
printf("Total number of element ");
scanf("%d",&total_element);
printf("\nEnter the numbers\n");
for(i=0;i<total_element;i++)
scanf("%d",&num[i]);
range=total_element-1;
for(i=0;i<total_element-1;i++)
for(j=0;j<range-i;j++)
if(num[j]>num[j+1])
{
temp=num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
printf("\nAfter Sorting\n");
for(i=0;i<total_element;i++)
printf("%d ",num[i]);
getch();
}
#include<stdio.h>
void main()
{
int num[20],total_element,range,i,j,temp;
clrscr();
printf("Total number of element ");
scanf("%d",&total_element);
printf("\nEnter the numbers\n");
for(i=0;i<total_element;i++)
scanf("%d",&num[i]);
range=total_element-1;
for(i=0;i<total_element-1;i++)
for(j=0;j<range-i;j++)
if(num[j]>num[j+1])
{
temp=num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
printf("\nAfter Sorting\n");
for(i=0;i<total_element;i++)
printf("%d ",num[i]);
getch();
}