#include<iostream>
using namespace std;
int main()
{
int len1;
cout<<"please enter the length of arrayn 1";
cin>>len1;
cout<<"creating array now";
int *arr1= new int[len1];
cout<<"please enter the elements now";
for(int i=0;i<len1;i++)
{
cin>>arr1[i];
cout<<endl;
}
return 0;
cout<<arr1;
delete [] arr1;
}
In the above code, the program stops execution after the first cin.(i know that the variable needs to be initialized first)
Q1) why do we need to initialize the variable first?? Should it not take some garbage value or NULL?