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

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

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

Q.23Medium

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

Q.24Medium

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

Q.25Medium

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

Q.26Medium

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

Q.27Medium

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

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

Q.29Medium

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

Q.30Medium

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

Q.31Medium

Which of the following about preprocessor is TRUE?

Q.32Medium

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

Q.33Medium

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

Q.34Medium

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

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

Q.36Medium

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

Q.37Medium

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

Q.38Medium

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

Q.39Medium

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

Q.40Medium

Which statement about __VA_ARGS__ in variadic macros is CORRECT?