C Programming
C language from basics to advanced placement prep
303 Questions 10 Topics Take Test
Advertisement
Showing 11–20 of 303 questions
Q.11 Easy Preprocessor
What does the ## operator in preprocessor do?
A Stringification
B Token pasting
C Comparison
D Bitwise AND
Correct Answer:  B. Token pasting
EXPLANATION

The ## operator concatenates two tokens into one. For example, #define CONCAT(a,b) a##b creates CONCAT(hello, world) → helloworld.

Take Test
Q.12 Easy Preprocessor
What is the output of the following code?
#define PI 3.14
int main() { printf("%f", PI); return 0; }
A 3.14
B Compilation error
C 3.140000
D Undefined behavior
Correct Answer:  C. 3.140000
EXPLANATION

PI is replaced by 3.14 during preprocessing. When printed with %f format specifier, it displays as 3.140000 (default 6 decimal places).

Take Test
Q.13 Easy Preprocessor
Which of the following correctly demonstrates the use of conditional compilation?
A #ifdef DEBUG printf("Debug mode"); #endif
B #if DEBUG printf("Debug mode"); #endif
C #ifelse DEBUG printf("Debug mode"); #endif
D #iftrue DEBUG
Correct Answer:  A. #ifdef DEBUG printf("Debug mode"); #endif
EXPLANATION

Option A uses #ifdef to check if DEBUG is defined, which is correct for conditional compilation. Option B would check if DEBUG has a non-zero value (expression-based). Options C and D have invalid syntax.

Take Test
Q.14 Easy Preprocessor
Which header file must be included to use the NULL macro?
A
B
C
D Any of the above
Correct Answer:  D. Any of the above
EXPLANATION

NULL is defined in multiple standard headers including <stdio.h>, <stdlib.h>, <stddef.h>, <string.h>, and others. Any of these can be included to use NULL.

Take Test
Q.15 Easy Preprocessor
Consider the following code:
#define PI 3.14
#undef PI
#define PI 3.14159
What is the value of PI after execution?
A 3.14
B 3.14159
C Compilation error
D Undefined
Correct Answer:  B. 3.14159
EXPLANATION

#undef removes the previous definition of PI. The subsequent #define redefines PI as 3.14159. This is valid C syntax and the final value of PI is 3.14159.

Take Test
Advertisement
Q.16 Easy Preprocessor
Which of the following is a difference between #include and #include "file.h"?
A Both search in the same directories
B searches system directories first, "file.h" searches current directory first
C "file.h" is for local files, is for system files
D Both B and C
Correct Answer:  D. Both B and C
EXPLANATION

The angle bracket version searches in standard system directories first, while quoted version searches in the current/local directory first. Both statements B and C correctly describe this distinction.

Take Test
Q.17 Easy Preprocessor
Which preprocessor directive is used to define a constant that cannot be changed during program execution?
A #define
B #const
C #constant
D #fixed
Correct Answer:  A. #define
EXPLANATION

#define is used to create macro definitions and constants at compile time. #const, #constant, and #fixed are not valid preprocessor directives in C.

Take Test
Q.18 Easy Preprocessor
Which header file is included using angle brackets in standard C library?
A #include "stdio.h"
B #include
C #include {stdio.h}
D #include [stdio.h]
Correct Answer:  B. #include
EXPLANATION

Standard library headers like stdio.h, stdlib.h, string.h are included using angle brackets #include <filename>.

Take Test
Q.19 Easy Preprocessor
Which preprocessor directive should be used to check if a macro is NOT defined?
A #ifdef
B #ifndef
C #if !defined
D Both B and C
Correct Answer:  D. Both B and C
EXPLANATION

Both #ifndef and #if !defined(MACRO) are equivalent and check if a macro is not defined. #ifndef is simpler syntax for this specific case.

Take Test
Q.20 Easy Preprocessor
Which statement about preprocessor is TRUE?
A Preprocessor directives are executed during runtime
B Preprocessor directives start with # and are processed before compilation
C Preprocessor can access variables during compilation
D Preprocessor directives are part of the compiled binary
Correct Answer:  B. Preprocessor directives start with # and are processed before compilation
EXPLANATION

Preprocessor directives (starting with #) are processed before the actual compilation by a separate preprocessor tool. They perform text substitution and conditional compilation.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips