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

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

Q.22Medium

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

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

Q.24Medium

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

Q.25Medium

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

Q.26Medium

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

Q.27Medium

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

Q.28Medium

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);

Q.29Medium

What is the purpose of #pragma pack() directive?

Q.30Medium

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

Q.31Medium

What is the output of: #define MIN(a,b) ((a)<(b)?(a):(b)) int main() { printf("%d", MIN(10, 5*2)); return 0; }

Q.32Medium

Which of the following about preprocessor is TRUE?

Q.33Medium

What is the correct way to define a multi-line macro in C?

Q.34Medium

Consider the preprocessor directive #define MAX 100. If this macro is used in multiple source files, which statement is TRUE?

Q.35Medium

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; }

Q.36Medium

What will be the result of executing the following? #define PRINT(x) printf(#x) int main() { int a = 10; PRINT(a); return 0; }

Q.37Medium

What is the purpose of #line directive in C preprocessing?

Q.38Medium

Which of the following correctly uses #pragma once for header file protection in 2024 standards?

Q.39Medium

Which preprocessor directive is used to generate a compiler warning or error message at compile time?

Q.40Medium

Consider nested macro expansion: #define A B #define B 5 printf("%d", A); What is printed?