Determine output:
#include<stdio.h>
#define clrscr() 100
void main()
{
clrscr();
printf("%dn", clrscr());
}
#include<stdio.h>
#define clrscr() 100
void main()
{
clrscr();
printf("%dn", clrscr());
}
A. 0
B. 1
C. 100
D. Error
Answer: Option C
Solution(By Examveda Team)
Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :
void main()
{
100;
printf("%d\n", 100);
}
Note: 100; is an executable statement but with no action. So it doesn't give any problem.
What is the purpose of the C preprocessor in C programming?
A. Compile C code
B. Optimize code
C. Preprocess code before compilation
D. Execute code
A. #define
B. #include
C. #ifdef
D. #pragma
What is the purpose of the #define directive in C preprocessing?
A. To include a header file
B. To define a macro
C. To declare a constant
D. To declare a variable
In C, which directive is used to conditionally include code based on preprocessor macros?
A. #ifdef
B. #ifndef
C. #if
D. #else
Join The Discussion