THE TECH GUY
TECHNOLOGY-ANDROID-IOS-WINDOWS-COMPUTER
Showing posts with label
array
.
Show all posts
Showing posts with label
array
.
Show all posts
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();
}
Older Posts
Home
Subscribe to:
Posts (Atom)