What will be the output of the following C code? [code]#include<stdio.h> #define hello main() { #ifdef hello #define hi 4

What will be the output of the following C code?
Code:
#include<stdio.h>
#define hello 
main()
{
    #ifdef hello
    #define hi 4
    #else
    #define hi 5
    #endif
    printf("%d",hi);
}
A. 4
B. 5
C. 45
D. error
 
Answer: a
Explanation: The code shown above illustrates #define, #ifdef, #else, #endif. Since the identifier hello is defined (condition of #if is true), another identifier names hi is defined and it’s value is 4. If hello was not defined, then the value of hi would be 5.
 

Tìm kiếm

Back
Top