GATE CS 2018 · Question 12 · Programming and Data Structures · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Consider the following C program.
#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:

  1. (A) 0, c
  2. (B) 0, a+2
  3. (C) '0', 'a+2'
  4. (D) '0', 'c'
Answer

Answer (A)

Answer from the official GATE CS 2018 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes