Q3 How can dynamic array of pointers(to integers) of size 100 can be
created using new in C++?
A) int *arr = new int *[100];
B) int **arr = new int *[100];
C) int *arr = new int [100];
D) int arr = new int [100];
B is the right option for the given question…but please explain the use cases or when or for what is the other options used?Is option A and D is correct or the initialisation is itself wrong?what does option C do?
Pointers mcq doubt
A is incorrect
C is used for creating dynamic array of integer of size 100
D is incorrect
B is creating the dynamic array of pointer of size 100
what is the difference between B and C option?
is D incorrect because new is used for only pointers?or any other reason?
in B dynamic array of pointer(int*) is created
but in C dynamic array of int is created
yes
the dynamic array created should be stored in a pointer
in B option are we creating 2D array and in C option are we creating 1D array?
No in both case one D array is created
But the type of array is different
in first case integer array is created but in second case pointer array is created
Means data type of first array is int
but data type of second integer is pointer
in first array we can place any integer but in second array we can place any pointer