Untitled
unknown
plain_text
2 years ago
613 B
1
Indexable
Never
#include<stdio.h> void insert(int a[],int n) { int i,j,temp; for(i=1;i<n;i++) { temp=a[i]; j=i-1; while(j>=0&& temp<=a[j]) { a[j+1]=a[j]; j=j-1; } a[j+1]=temp; } } void printArr(int a[],int n) { int i; for(i=0;i<n;i++) printf("%d",a[i]); } int main() { int a[] = {12,31,25,8,32,17}; int n=sizeof(a)/sizeof(a[0]); printf("before sorting array elements are-\n"); printArr(a,n); insert(a,n); printf("\n after sorting array elements are-\n"); printArr(a,n); return 0; }