What will be the output of the following program?
#include<stdio.h>
#define square(x) x*x
void main()
{
int i;
i = 64/square(4);
printf("%d", i);
}
#include<stdio.h>
#define square(x) x*x
void main()
{
int i;
i = 64/square(4);
printf("%d", i);
}
A. 4
B. 64
C. 16
D. None of These
Answer: Option B
Solution(By Examveda Team)
The macro call square(4) will be substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority and associativity left to right, so the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64.
Join The Discussion
Comments ( 1 )
Related Questions on C Preprocessor
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
square(4) = 16;
therefore,
i = 64/16 = 4;
the answer is 4.