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

What will be the output of this preprocessor code? #define ADD(a,b) a+b int result = ADD(2,3)*2;

Q.922Easy

Consider the following code: #define PI 3.14 #undef PI #define PI 3.14159 What is the value of PI after execution?

Q.923Medium

What happens when you use stringification operator (#) in a macro? #define STRINGIFY(x) #x

Q.924Medium

What is the token pasting operator (##) used for in C preprocessor?

Q.925Medium

Which of the following macro definitions will correctly compute the absolute value? #define ABS(x) ((x)<0?-(x):(x))

Q.926Hard

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

Q.927Medium

What will be the result of this code? #define MAX(a,b) (a>b?a:b) int x = MAX(MAX(2,5), MAX(3,4));

Q.928Hard

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

Q.929Easy

Which header file must be included to use the NULL macro?

Q.930Hard

What is a dangling macro problem in C?

Q.931Medium

What will happen when this code is compiled? #define SIZE 10 int arr[SIZE]; #undef SIZE int arr2[SIZE];

Q.932Easy

Which of the following correctly demonstrates the use of conditional compilation?

Q.933Medium

What is the purpose of predefined macros like __LINE__ and __FILE__?

Q.934Hard

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

Q.935Easy

What is the output of the following code? #define PI 3.14 int main() { printf("%f", PI); return 0; }

Q.936Medium

What is the output of: #define SQUARE(x) x*x int main() { int a = SQUARE(2+3); printf("%d", a); return 0; }

Q.937Medium

Which of the following correctly defines a macro with multiple statements?

Q.938Easy

What does the ## operator in preprocessor do?

Q.939Medium

What is the output of: #define STR(x) #x int main() { printf("%s", STR(Hello)); return 0; }

Q.940Easy

Which predefined macro gives the line number in the source file?