Question 2,7 in pointers mcq in Algo++

in question 2 i am not getting what statements are trying to say… and in question 7 I am not able to understand the code

Hello @sharmaharsh9944,

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 the address of any type and can be typecasted 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.

Ques7.
That statement is equivalent to:
sum+=arr[i][i++];

Hope, this would help.
Give a like, if you are satisfied.

in ques 7
*(arr+i) gives the pointer to first element in ith row.
((arr+i)+(i++)) gives the ith element in ith row and increments i.

ques 2 is expalined well above.

Mark if resolved :slight_smile: