Creation of array

While working with arrays, we create array of maximum size, let’s say a [1000] & what if user have only 10 or 20 elements? Won’t it lead to loss of memory?

hello @gambhirrahul0
yeah that is a wastage of memory.
that is why u should create array after reading size.
like->
int size;
cin>>size;
int a[size];