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

What is the output of this code?
#define ADD(a,b) a+b
int result = ADD(5,3)*2;

Q.2Medium

What is the purpose of the #ifdef directive?

Q.3Medium

Which of the following shows the correct order of preprocessor directives in a C program?

Q.4Medium

What is the difference between #include <stdio.h> and #include "myheader.h"?

Q.5Medium

What will happen if you define the same macro twice with different values?

Q.6Medium

What is the output of this code?
#define SWAP(a,b) {int temp=a; a=b; b=temp;}
int x=5, y=10;
SWAP(x,y);
printf("%d %d", x, y);

Q.7Medium

What does the ## operator do in a macro?

Q.8Medium

What is the output?
#define STR(x) #x
printf("%s", STR(hello));

Q.9Medium

Consider the following code:
#define MAX 100
#define MAX 200
What will be the result?

Q.10Medium

What will be the output of the following code?
#define SQUARE(x) x*x
int result = SQUARE(2+3);
printf("%d", result);

Q.11Medium

What will be printed?
#define DEBUG 1
#if DEBUG
printf("Debug mode ON");
#else
printf("Debug mode OFF");
#endif

Q.12Medium

What does the following macro do?
#define CONCATENATE(a,b) a##b

Q.13Medium

What is the output of:
#define STR(x) #x
printf("%s", STR(HELLO));

Q.14Medium

What happens when you use #undef on a macro?

Q.15Medium

Which of the following will correctly find the maximum of two numbers using a macro?

Q.16Medium

Which of the following is the correct way to prevent multiple inclusion of a header file?

Q.17Medium

What is the output of the following code?
#define SQUARE(x) x*x
int a = SQUARE(5+3);

Q.18Medium

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

Q.19Medium

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

Q.20Medium

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