Vidyalelo
C Programming · Q36

Pointer

Programming · C Programming · question 36

Q36

Determine output: #include void main() char *p = NULL; char *q = 0; if(p) printf(" p "); else printf("nullp"); if(q) printf("q"); else printf(" nullq");

A.
p q
B.
Depends on the compiler
C.
x nullq where x can be p or nullp depending on the value of NULL
D.
nullp nullq
Answer

Answer: Option D

Solution

Answer: Option D
Solution:

char *p = NULL is same as char *q = 0.
In both declarations p and q are initialized to null.