C
Programming and Technical
Programming
Program
What is the output of this C code?
#include
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("qn");
else
printf(" nullqn");
}
a) nullp nullq
b) Depends on the compiler
c) x nullq where x can be p or nullp depending on the value of NULL
d) p q
Read Solution (Total 4)
-
- Option a is the right answer.
It prints "nullp nullqn" because NULL is treated as false so it prints nullp in first if else clause and prints nullqn in second if else clause as 0 is treated as false. - 11 years agoHelpfull: Yes(8) No(2)
- d)p q
p and q contains the addresses - 11 years agoHelpfull: Yes(1) No(1)
- a) nullp nullq
- 10 years agoHelpfull: Yes(0) No(1)
- Ans option is a
- 10 years agoHelpfull: Yes(0) No(0)
C Other Question