Created
August 13, 2018 16:45
-
-
Save krishnaprajapat/01164e075913563669d21792b4ae6d21 to your computer and use it in GitHub Desktop.
Insertion sort using c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void sort(int a[],int n) | |
{ | |
int i,j,t; | |
for(i=1;i<=4;i++){ | |
t=a[i]; | |
for(j=i-1;j>=0&&a[j]>t;j--) | |
a[j+1]=a[j]; | |
a[j+1]=t;} | |
for(i=0;i<5;i++) | |
printf("\n %d",a[i]); | |
} | |
int main() | |
{ | |
int a[5],i; | |
for(i=0;i<5;i++) | |
scanf("%d",&a[i]); | |
sort(a,5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment