THE TECH GUY
TECHNOLOGY-ANDROID-IOS-WINDOWS-COMPUTER
Tuesday, 7 June 2016
C program to sort elements in an array:
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,t,arr[]={1,2,4,3,6,5};
for(i=0;i<6;i++)
{
for(j=i+1;j<6;j++)
{
if(arr[i]>arr[j])
{
t=arr[i];
arr[i]=arr[j];
arr[j]=t;
}
}
}
for(i=0;i<6;i++)
printf("%d ",arr[i]);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment