Examveda
Examveda

Determine output:
#include <stdio.h>
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: Option D

Solution(By Examveda Team)

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


This Question Belongs to C Program >> Pointer

Join The Discussion

Comments ( 3 )

  1. Vedant Kulkarni
    Vedant Kulkarni :
    4 years ago

    They are using 64 bit compiler so the size of pointer in 64 bit compiler is 8 byte...
    Is it okay frinds???

  2. Manuja Krishna
    Manuja Krishna :
    6 years ago

    Please anyone explain me gow it goes to else loop ,i am getting it

  3. Jagadish Jaggu
    Jagadish Jaggu :
    7 years ago

    Here if (p) that p gives address n not a value and how it goes to else

Related Questions on Pointer