Insertion sort program

#include
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int t=1;t<n;t++){
int j=t-1;
int e=a[t];
int f=0;
while(j>=0 && a[j]>e){

        a[j+1]=a[j];
        j--;
        f=0;
    }
        f=1;
        a[j+1]=e;
}
for(int i=0;i<n;i++){
    cout<<a[i];
}
return 0;

}

please check it and tell me this is correct without using function we just have to describe variable and put it there but in function we don’t need to compare just directly it will give please tell

@tarshid7 please share your code using ide.codingblocks.com
Also please describe your doubt I am unable to understand

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.