🧱 Structs, Unions & Undefined Behaviour
Why it matters: Layout and sizeof questions test your model of memory; the undefined-behaviour checklist lets you answer "what will this program print?" correctly when the answer is "anything".
Subtopics
Each subtopic has its own page: idea, why, how, example, play, check. Mark each one understood when it clicks. 0 of 4 done.
Formulas
What GATE asks from this
Question types seen repeatedly in past papers. More stars means more frequent.
Ratings are approximate, based on recurring patterns in past GATE CSE papers.
Previous year questions
2 real questions from the official GATE CSE papers (2017 to 2018), newest first, each with the official answer key and a worked solution. Questions are the property of the GATE organising institutes; this copy is for your personal study.
2 questions · 0 correct of 0 attempted · marks 0 / 2
#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:struct data {
int marks [100];
char grade;
int cnumber;
};
struct data student;The base address of student is available in register R1. The field student.grade can be accessed efficiently using