The below given code gives logical error, pls try to give a explanation WHY the given code is not working. Thanks
/*const*/
#include<iostream>
#define n 10
using namespace std;
int main(){
int i=0, user_val=0, arr[n]={0, 1, 2, 3, 4, 5, 6, 7, 8}, temp=0;
cout<<"enter the index to add the number"<<endl;
cin>>user_val;
for(i=n; i>user_val; i--){
cout<<"loop"<<i<<endl;
arr[i+1]=arr[i];
}
cout<<"enter the number to add"<<endl;
cin>>temp;
arr[i]=temp;
for(int j=0; j<n; j++){
cout<<endl<<arr[j];
}
}