Skip to content

Commit 115d6fb

Browse files
committed
inseration sort c-basics
1 parent 3bd9f64 commit 115d6fb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

arrayinsertionsort.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<stdio.h>
2+
void main()
3+
{
4+
int a[50],n,i,j,temp;
5+
printf("Enter the number of elements\n");
6+
scanf("%d",&n);
7+
printf("Enter the elements of array\n");
8+
for(i=0;i<n;i++)
9+
{
10+
scanf("%d",&a[i]);
11+
}
12+
for(i=0;i<n;i++)
13+
{
14+
for(j=0;j<n;j++)
15+
{
16+
if(a[i]<a[j])
17+
{
18+
temp=a[i];
19+
a[i]=a[j];
20+
a[j]=temp;
21+
}
22+
}
23+
}
24+
for(i=0;i<n;i++)
25+
{
26+
printf(" %d",a[i]);
27+
}
28+
}

0 commit comments

Comments
 (0)