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

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

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

Q.183Hard

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

Q.184Hard

What is a dangling macro problem in C?

Q.185Hard

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

Q.186Hard

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

Q.187Hard

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

Q.188Hard

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

Q.189Hard

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

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

Q.191Hard

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

Q.192Hard

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

Q.193Hard

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