iGET

C Programming - MCQ Practice Questions

C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.

972 questions | 100% Free

Q.461Medium

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

Q.462Medium

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

Q.463Medium

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

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

Q.465Medium

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

Q.466Medium

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

Q.467Medium

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

Q.468Medium

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

Q.469Medium

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

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

Q.471Medium

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

Q.472Medium

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

Q.473Medium

Which of the following about preprocessor is TRUE?

Q.474Medium

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

Q.475Medium

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

Q.476Medium

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

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

Q.478Medium

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

Q.479Medium

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

Q.480Medium

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