Simultaneous execution of both if and else blocks

后端 未结 13 2316
难免孤独
难免孤独 2020-12-10 17:45

In C or C++

if ( x )
    statement1;
else
    statement2;

For what value of x will both statements be executed?

I know

13条回答
  •  借酒劲吻你
    2020-12-10 17:51

    You can use this:

    #include  
    int main() 
    { 
    if (//some condition//)
    { 
        IF:{
        printf("Hello "); //Code for if block.
         } 
        goto ELSE;
    } 
    else
    {  
        goto IF;
        ELSE:{
          printf("world");//code for else block.
             }
    }
    return 0; 
    } 
    

    Output: Hello world

提交回复
热议问题