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.41Easy

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

Q.42Medium

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

Q.43Medium

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

Q.44Medium

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

Q.45Medium

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.46Hard

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

Q.47Easy

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

Q.48Hard

What is a dangling macro problem in C?

Q.49Medium

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

Q.50Easy

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

Q.51Medium

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

Q.52Hard

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

Q.53Easy

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

Q.54Medium

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

Q.55Medium

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

Q.56Easy

What does the ## operator in preprocessor do?

Q.57Medium

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

Q.58Easy

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

Q.59Medium

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

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