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.1Hard

Which statement about #define is TRUE?

Q.2Hard

What is the problem with this macro?
#define DOUBLE(x) x*x
int result = DOUBLE(2+3);

Q.3Hard

What will be the output?
#define MIN(a,b) ((a)<(b)?(a):(b))
int x=5; int y=10;
int z = MIN(x++, y++);

Q.4Hard

What is the difference between #if and #ifdef?

Q.5Hard

What preprocessor features should be avoided for safer code?

Q.6Hard

Consider:
#define MAX(a,b) ((a)>(b)?(a):(b))
Which advantage does this provide?

Q.7Hard

What will be output?
#define PRINT(x) printf(#x " = %d\n", x)
PRINT(5+3);

Q.8Hard

What is the result of the following?
#define MIN(x,y) ((x)<(y)?(x):(y))
int a=5, b=3;
int result = MIN(a++, b++);

Q.9Hard

What does the following preprocessor do?
#define OFFSET(type, field) ((size_t)&(((type *)0)->field))

Q.10Hard

How many times is the argument evaluated in this macro?
#define CUBE(x) ((x)*(x)*(x))
int result = CUBE(a++);

Q.11Hard

What is a dangling macro problem in C?

Q.12Hard

Consider the following macro:
#define SWAP(a,b) {int temp=a; a=b; b=temp;}
What issue might occur with this macro?

Q.13Hard

What will happen if we define a macro with the same name as a C standard library function?

Q.14Hard

Consider the macro: #define AREA(r) 3.14*r*r
What is the issue and how to fix it?

Q.15Hard

Which of the following will correctly print the number of arguments passed to a variadic macro in C99?

Q.16Hard

Consider: #define SWAP(a,b) {int temp=a; a=b; b=temp;}
If used in an if-else without braces, which problem occurs?
if(condition) SWAP(x,y); else printf("No swap");

Q.17Hard

What does the following preprocessor output?
#define VERSION "2024"
#define STR(x) #x
printf(STR(VERSION));

Q.18Hard

What will be the output of:
#define MAX(a,b) ((a)>(b)?(a):(b))
int main() { printf("%d", MAX(5++, 10)); return 0; }

Q.19Hard

Which of the following will cause infinite recursion when used?
#define RECURSE() RECURSE()

Q.20Hard

What will happen if a macro is defined multiple times with different definitions in the same compilation unit?
#define SIZE 10
#define SIZE 20