Home » C Programming » Pointers » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    char *ptr1 = NULL;
    char *ptr2 = 0;
    if (ptr1)
    printf(" ptr1 ");
    else
    printf("Null ptr1");
    if (ptr2)
    printf("ptr2\n");
    else
    printf("\nNull ptr2\n");
    }
    1. Null ptr1 or Null ptr2 depending on the value of NULL
    2. Null ptr2
    3. Null ptr1
    4. Null ptr1
      Null ptr2
    5. None of these
Correct Option: D

Null ptr1
Null ptr2



Your comments will be displayed only after manual approval.