What will be the output of the following C code? [code]#define display(text) "$" #text main() { printf(display(hello world)); }[/code]

What will be the output of the following C code?
Code:
#define display(text) "$" #text
main()
{
    printf(display(hello	   world));
}
A. hello world
B. $helloworld
C. $hello world
D. error
 
Answer: c
Explanation: The output of the code shown above is $hello world
The argument “hello  world” is passed to the macro text. The symbol “$” is present from before. In the resulting string, all the blank spaces are replaced by a single blank space. In addition to this, “$” is concatenated to the beginning of the resultant string.
 

Tìm kiếm

Back
Top