Hello @IronVenom,
Ques 2:
A. Option A is wrong, because we cannot perform pointers asthmatics with void pointers.
D. So, option D is also incorrect.
B. A void pointer is a pointer that has no associated data type with it. A void pointer can hold address of any type and can be typcasted to any type.
nt a = 10;
char b = ‘x’;
void *p = &a; // void pointer holds address of int ‘a’
p = &b; // void pointer holds address of char ‘b’.
We cannot use it directly.
You are required to refer them to an object of some type before using them like:
void *p = &a;
Thus, this option is also wrong.
C. A c pointer knows the types of pointers and indirectly referenced data items at runtime.
We have already discussed that a must have a type before using it. So, it knows the type of data it can point to.
Also, the *p (referenced data item i.e. the value stored at the location pointed by it) is accessed at the time of execution or at the time , when we are using it.
Ques 3:
The option B must be correct:
int **arr=new int *[100];
Here, new keyword is used for dynamic memory allocation.
c) option will create a pointer to integer array of length 100.
b) will create a pointer to arrays of pointer of integer type, with size 100.
int **arr; It is the pointer to pointer
int **arr= new int *[100]; it is required dynamic arrays of pointer.
Hope, this would help.
Give a like, if you are satisfied.