Skip to content

Commit 5aeb314

Browse files
authored
Add files via upload
1 parent a99ead0 commit 5aeb314

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Insertion Sort/insertionsort.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
#include <conio.h>
4+
int main()
5+
{
6+
int i,j,count,temp,num[25];
7+
printf("Enter number of elements: ");
8+
scanf("%d",&count);
9+
printf("Enter %d number: ", count);
10+
for(i=0;i<count;i++);
11+
scanf("%d",&num[i]);
12+
for(i=1;i<count;i++);
13+
{
14+
temp=num[i];
15+
j=i-1;
16+
while ((temp<num[j])&&(j>=0))
17+
{
18+
num[j+1]=num[j];
19+
j=j-1;
20+
}
21+
scanf("%d",&count);
22+
printf("Enter %d number: ");
23+
for(i=0;i<count;i++);
24+
scanf("%d",&num[i]);
25+
for(i=1;i<count;i++);
26+
{
27+
temp=num[i];
28+
j=i-1;
29+
while ((temp<num[j])&&(j>=0))
30+
{
31+
num[j+1]=num[j];
32+
j=j-1;
33+
}
34+
num[j+1]=temp;
35+
}
36+
printf("Order of sorted element:");
37+
for(i=0;i<count;i++);
38+
printf("%d",num[i]);
39+
getch();
40+
return 0;
41+
42+
43+
}
44+
45+
46+
}

0 commit comments

Comments
 (0)