Output question on pointer


#1

Consider the following code snippet:
P= (int *)malloc(sizeof(int));
q=&p;
r=&q;
write the data type of p,q and r

a) Int *p ; int **q; int ***r
b) Int **p ; int ** q ; int * r;
c) Int ***p ; int ** q; int **r;
d) None of the above


#2

Answer A

P -> is a pointer; (int *p)
Q -> is a pointer that holds address of P; (int **q)
R -> is a pointer that holds address of Q; (int ***r)


#3

p is a normal pointer. so (intp).
q contains the address of pointer p. so (intq).
r contains the address of pointer q. so (int
r)

Here in the sollution:-
p is normal pointer
q is double pointer
while r is a triple pointer.