// write a program in c to implement // Insertion sort #include #include int main(){ /* Here i & j for loop numers, temp for swapping, * num for total arr of elements, arr[] to * store the input numbers in array. You can increase * or decrease the size of arr[] array as per requirement */ int i, j, num, temp, arr[25]; printf("Enter the number of element\n"); scanf("%d",&num); printf("Enter %d elements:\n ", num); // This loop would store the input numbers in array for(i=0;i=0)){ arr[j+1]=arr[j]; j=j-1; } arr[j+1]=temp; } printf("Sorted elements is : "); for(i=0;i
Enter the number of element 7 Enter 7 elements: 44 3 -7 90 3 420 22 Sorted elements is : -7 3 3 22 44 90 420
0 Comments