Question #8: Given the code below, the variable y can be accessed in which blocks of code?

Question #8: Given the code below, the variable y can be accessed in which blocks of code?
55% on 11229 times asked

1  int main(int argc, char** argv)
            2  {
            3
            4   if ( argc > 10) )
            5   {
            6
            7   }
            8   else if (int y = argc - 1 )
            9   {
            10
            11  }
            12  else
            13  {
            14
            15  }
            16
            17  return 0;
            18  }
lines 4-15
lines 4-17
lines 8-11
lines 8-15 - correct
lines 8-17

description: The variable declared in the else-if did not exist before its declaration and can not be used after the end of the else clause. Variables declared in conditions of if,else-if,else structures can be used in all subsequent conditions and bodies of the if,else-if,else structure.

原文地址:https://www.cnblogs.com/rickiedu/p/1454267.html