Why array is declared as int *arr

Why do we declare the array as int *arr, instead of int arr. Why do we put * ?

hello @sonalbera

we can declare array by two ways.
one is static allocation like ->
int a[n];

one is dynamic allocation like->
int *a = new int[n];
here new operator will allocate memory of n block and return its base address which we are storing in pointer a.

both will work in same manner,u can use any of them.

for classes and objects use dynamic allocation because n is not known to us before hand.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.