1,489 views
2 votes
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 votes
4 votes

when the program will execute 

printf(scanfscanf);

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

Related questions

0 votes
0 votes
1 answer
1
aditi19 asked Sep 3, 2018
328 views
tokens passed to macros are treated as int, float or string?