int arr[1000];
int N;
cin >>N;
for(int i=0;i<N;i++)
{
cin >> arr[i];
}
if i use this way for taking input of array , am i not wasting array size (as i fill only n input in an array of size 1000}
how to avoid this
int arr[1000];
int N;
cin >>N;
for(int i=0;i<N;i++)
{
cin >> arr[i];
}
if i use this way for taking input of array , am i not wasting array size (as i fill only n input in an array of size 1000}
how to avoid this
use dynamic allocation of array
int *arr=new int [n];
using this an array of size n only is created