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

后端 未结 30 2868
旧时难觅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:14

    Just put the code before or after the if..else block.

    Alternatively, if you have an "if, else if, else" block where you want to execute code in some (but not all) branches, just put it in a separate function and call that function within each block.

提交回复
热议问题