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

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

    int main()
    {
        runIfElse(true);
        runIfElse(false);
    
        return 0;
    }
    
    void runIfElse(bool p)
    {
        if(p)
        {
         // do if
        }
        else
        {
         // do else
        }
    }
    

提交回复
热议问题