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
Consider the macro: #define ADD(a,b) (a)+(b) What is the result of: int x = ADD(3,4) * 2;
Consider: #define MAX(a,b) ((a)>(b)?(a):(b)) Which advantage does this provide?
What will be output? #define PRINT(x) printf(#x " = %d\n", x) PRINT(5+3);
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++);
What does the following preprocessor do? #define OFFSET(type, field) ((size_t)&(((type *)0)->field))
What is the output of: #define MULTIPLY(x,y) x*y int ans = MULTIPLY(3+2, 4+5);
How many times is the argument evaluated in this macro? #define CUBE(x) ((x)*(x)*(x)) int result = CUBE(a++);
What is a dangling macro problem in C?
Consider the following macro: #define SWAP(a,b) {int temp=a; a=b; b=temp;} What issue might occur with this macro?
What will happen if we define a macro with the same name as a C standard library function?
Consider the macro: #define AREA(r) 3.14*r*r What is the issue and how to fix it?
Which of the following will correctly print the number of arguments passed to a variadic macro in C99?
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");
What does the following preprocessor output? #define VERSION "2024" #define STR(x) #x printf(STR(VERSION));
What will be the output of: #define MAX(a,b) ((a)>(b)?(a):(b)) int main() { printf("%d", MAX(5++, 10)); return 0; }
Which of the following will cause infinite recursion when used? #define RECURSE() RECURSE()
What will happen if a macro is defined multiple times with different definitions in the same compilation unit? #define SIZE 10 #define SIZE 20