GATE | CS | 2018 | C Programming | Pointers | Question 33

Last Updated :
Discuss
Comments

Consider the following C program.

C
#include <stdio.h>
struct Ournode {
  char x, y, z;
};

int main() {
  struct Ournode p = {'1', '0', 'a' + 2};
  struct Ournode *q = &p;
  printf("%c, %c", *((char *)q + 1), *((char *)q + 2));
  return 0;
}

The output of this program is:

0, c

0, a+2

'0', 'a+2'

'0', 'c'

Share your thoughts in the comments