2,614 views
2 2 votes

# include <stdio.h>

# define scanf  "%s GeeksQuiz"

int main()

{

   printf(scanf, scanf);

   return 0;

}

(A) Compiler Error
(B) %s Geeks Quiz
(C) Geeks Quiz
(D) %s Geeks Quiz Geeks Quiz

1 Answer

Best answer
4 4 votes

when the program will execute 

printf(scanf, scanf);

both scanf will be replaced by a string "%s GeeksQuiz"

a statement will become printf("%s GeeksQuiz ", "%s GeeksQuiz ");

%s will act as a format specifier, it will print the string "%s GeeksQuiz" and then whatever message u are going to print like in our case, GeeksQuiz will be printed.

the final output will be:%sGeeksQuiz GeeksQuiz  

option D

• selected by
Position:
Show:

Related questions

0 0 votes
1 1 answer
868
868 views
aditi19 asked Sep 3, 2018
868 views
tokens passed to macros are treated as int, float or string?
0 0 votes
0 0 answers
901
901 views
slowpoke asked May 14, 2018
901 views
Can someone explain how the output is derived for the second printf statement.I have not understood how the value of x changed to 13 instead of 10. Detailed step by step ...