SIR MY I AM UNABLE TO UNDERSTAND WHAT IS THE PROBLEM WITH MY INSERTION SORT CODE

include <bits/stdc++.h>

using namespace std;

void print_array(int input[],int n)
{
for (int i = 0; i < n; ++i) {
cout << input[i] << " " ;
}
}

void insertion_sort(int input[], int n)
{
for (int i = 1; i <n ; i++) {

    for (int j = 0; j <i ; j++) {

        if(input[j]>=input[i]){
            int temp=input[i];

        for (int k = i; k >j ;k--) {
            input[k]=input[k-1];
            input[j]=temp;
        }
        }
    }
}
print_array(input, n);

}

int main ()
{
int n;
cin >> n;
int input[1000];
for (int i = 0; i <n ; i++) {
cin >> input[i];
}
insertion_sort(input, n);
}

why you are using 3 loops??
only 2 required

your code is completely incorrect for insertion sort

i have corrected the function you can see
Modified Code

sir your compiler is not working

yes there is some problem in codingblocks ide
we will shortly resolve the issue

you can try in your local complier for now

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.