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.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 the macro: #define ADD(a,b) (a)+(b) What is the result of: int x = ADD(3,4) * 2;

Q.7Hard

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

Q.8Hard

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

Q.9Hard

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

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

Q.11Hard

What is the output of: #define MULTIPLY(x,y) x*y int ans = MULTIPLY(3+2, 4+5);

Q.12Hard

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

Q.13Hard

What is a dangling macro problem in C?

Q.14Hard

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

Q.15Hard

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

Q.16Hard

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

Q.17Hard

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

Q.18Hard

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

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

Q.20Hard

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