You are using the value of n
before it has a value. Change your code to this
int n; // n does not have a value
cout<<"Enter the number of the element of the Array:";
cin>>n; // n gets value here
int arr[n]; // n is used here
You cannot use any variable before it has a value. That's a fundamental rule of C++.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…