iGET

C Programming - MCQ Practice Questions

C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.

972 questions | 100% Free

Q.321Medium

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

Q.322Medium

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

Q.323Medium

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

Q.324Medium

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

Q.325Medium

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

Q.326Medium

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.327Medium

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

Q.328Medium

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.329Medium

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

Q.330Medium

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

Q.331Medium

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

Q.332Medium

What is the purpose of using anonymous structures/unions?

Q.333Medium

Consider this structure: struct Complex { int real; int imag; }; If you want to create an array of 100 such structures, which declaration is correct?

Q.334Medium

Consider the following code:
struct Data {
int x;
char y;
double z;
};
Assuming int=4 bytes, char=1 byte, double=8 bytes, what is the size of struct Data due to padding?

Q.335Medium

Which feature in C allows you to define a structure without a tag name for use within another structure?

Q.336Medium

In the context of bit fields in structures, what is the maximum number of bits that can be allocated to a single member in standard C?

Q.337Medium

Which of the following statements about structure initialization in C is INCORRECT?

Q.338Medium

What does fgets() function do?

Q.339Medium

Which function writes formatted data to a file?

Q.340Medium

What is the purpose of ftell() function?