iGET

C Programming - MCQ Practice Questions

Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

978 questions | 100% Free

Q.21Medium

What happens when you access a union member that wasn't the last one to be written?

Q.22Medium

When comparing nested structures, which access method is INVALID? struct Address { char city[20]; }; struct Person { Address addr; }; Person p;

Q.23Medium

Which structure feature is most suitable for implementing a state machine with limited states?

Q.24Medium

What is the primary use case for unions in embedded systems?

Q.25Medium

What is the size of the following structure on a 32-bit system? struct Point { char c; int x; };

Q.26Medium

Which feature of structures makes them suitable for implementing linked lists?

Q.27Medium

What happens if you attempt to assign one structure variable to another of the same type?

Q.28Medium

Which of the following is a valid declaration of nested structure?

Q.29Medium

What is the primary advantage of using unions in embedded systems?

Q.30Medium

How can you create a structure that can hold either an integer or a floating-point number, but not both simultaneously?

Q.31Medium

What is the difference between 'struct' and 'typedef struct' in C?

Q.32Medium

What will be the output if you read a union member that was not last written to?

Q.33Medium

In a nested structure scenario, how do you access a member of the inner structure?

Q.34Medium

What is the size of the following structure on a 32-bit system? struct Point { char c; int x; double y; }

Q.35Medium

What will be the output of this code? union Data { int a; char b; }; union Data d; d.a = 257; printf("%d %c", d.a, d.b);

Q.36Medium

What is the size of the following union? union Test { int a[5]; char b[10]; double c; }

Q.37Medium

Consider a structure with bit fields: struct Flags { unsigned int flag1 : 1; unsigned int flag2 : 3; unsigned int flag3 : 4; }; What is the minimum size of this structure?

Q.38Medium

What will happen if you try to compare two structures using the == operator directly?

Q.39Medium

Which of the following is a valid way to pass a structure to a function?

Q.40Medium

In a nested structure scenario like struct A contains struct B, how do you access a member of B from A's variable?