Multiple choice technology programming languages

What is the value of the local variable x at the end of main? int x = 5; int main(int argc, char** argv) { int x = x; return 0; }

  1. 0

  2. 5

  3. undefined

  4. 1

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The local declaration int x = x; shadows the global x. The local x is initialized with its own, as-yet uninitialized value, resulting in undefined behavior and an indeterminate value. The global x = 5 is completely ignored.