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
Which of the following macro definitions will correctly compute the absolute value? #define ABS(x) ((x)<0?-(x):(x))
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));
What will happen when this code is compiled? #define SIZE 10 int arr[SIZE]; #undef SIZE int arr2[SIZE];
What is the purpose of predefined macros like __LINE__ and __FILE__?
What is the output of: #define SQUARE(x) x*x int main() { int a = SQUARE(2+3); printf("%d", a); return 0; }
Which of the following correctly defines a macro with multiple statements?
What is the output of: #define STR(x) #x int main() { printf("%s", STR(Hello)); return 0; }
What is the issue with this macro: #define MAX(a,b) a>b?a:b int x = MAX(2, 3); int y = MAX(++i, ++j);
What is the purpose of #pragma pack() directive?
What is the output of: #define ADD(x,y) (x+y) int main() { printf("%d", ADD(5,3)*2); return 0; }
What is the output of: #define MIN(a,b) ((a)<(b)?(a):(b)) int main() { printf("%d", MIN(10, 5*2)); return 0; }
Which of the following about preprocessor is TRUE?
What is the correct way to define a multi-line macro in C?
Consider the preprocessor directive #define MAX 100. If this macro is used in multiple source files, which statement is TRUE?
What is the output of the following code? #define SQUARE(x) x*x int main() { int a = 5; printf("%d", SQUARE(a+1)); return 0; }
What will be the result of executing the following? #define PRINT(x) printf(#x) int main() { int a = 10; PRINT(a); return 0; }
What is the purpose of #line directive in C preprocessing?
Which of the following correctly uses #pragma once for header file protection in 2024 standards?
Which preprocessor directive is used to generate a compiler warning or error message at compile time?
Consider nested macro expansion: #define A B #define B 5 printf("%d", A); What is printed?