What's the “condition” in C interview test?

后端 未结 30 2913
旧时难觅i
旧时难觅i 2020-12-05 02:37

Would it be possible to print Hello twice using single condition?

if  \"condition\"
  printf (\"Hello\");
else
  printf(\"World\");         


        
30条回答
  •  心在旅途
    2020-12-05 03:19

    Greg wrote:

    No matter what you use for condition, that snippet will either print "Hello", or "World", but never both.

    Well, this isn't true, but why you would want it to print both, I can't find a use case for. It's defeating the point of having an if statement. The likely "real" solution is to not use an if at all. Silly interview questions... :)

提交回复
热议问题