Implementation of insertion sort in c programming language
Data Structure Sorting (Article) Sorting (Program)
617Program:
#include int main() { int i,j,n,temp,a[30]; printf("Enter the number of elements:"); scanf("%d",&n); printf("\nEnter the elements\n"); for(i=0;i =0)) { a[j+1]=a[j]; //moves element forward j=j-1; } a[j+1]=temp; //insert element in proper place } printf("\nSorted list is as follows\n"); for(i=0;i
Output:
Enter the number of elements:8 Enter the elements 8 7 6 5 4 3 2 1 Sorted list is as follows 1 2 3 4 5 6 7 8 Press any key to continue . . .
Explanation:
This Particular section is dedicated to Programs only. If you want learn more about Data Structure. Then you can visit below links to get more depth on this subject.