Program for accepting values in array and sort them in ascending order.

Program for accepting values in array and sort them in ascending order.



/*Program for accepting values in array and sort them in ascending order.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,t;
clrscr();
printf("\nEnter 5 values in array: ");
for(i=0;i<=4;i++)
{
scanf("%d",&a[i]);
}
printf("\nBefore arranging array values are:");
for(i=0;i<=4;i++)
{
printf("%d\t",a[i]);
}
for(i=0;i<=4;i++)
{
for(j=i+1;j<=4;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("\nAfter arranging in accending order array values are: \n");
for(i=0;i<=4;i++)
printf("%d\t",a[i]) ;
getch();
}

Comments

Popular posts from this blog

Components of C language

Decision making using if statement

How to make payment for final certificate, migration, provisional for the students of last semester of ptu?