hello i am new to c++ programming. here are two methods of allocation of dynamic arrays and both give the same output. i want to know what is the difference between the two.
1)here is method 1 using new and delete :
#include<iostream>
using namespace std;
int main()
{
 int n;
 cout<<"enter the array size : ";
 cin>>n;
 int *arr = new int[n];              
 cout<<"enter the array elements: ";
 for(int i=0;i<n;i++)
    {
     cin>>arr[i];
    }
 cout<<"array elements are: ";
 for(int i=0;i<n;i++)
    {
     cout<<arr[i]<<" ";
    }   
 cout<<"\n";
 delete [] arr;
 return 0;                   
}
2)here is method two :
#include<iostream>
using namespace std;
int main()
{
 int n;
 cout<<"enter the array size : ";
 cin>>n;
 int arr[n];               
 cout<<"enter the array elements: ";
 for(int i=0;i<n;i++)
    {
     cin>>arr[i];
    }
 cout<<"array elements are: ";
 for(int i=0;i<n;i++)
    {
     cout<<arr[i]<<" ";
    }   
 cout<<"\n";                   
 return 0;
}
