Multiple choice

What will be the output of the under given program? #include<iosteam.h> void main() { int k; cout<<”k=”<<k; }

  1. An error

  2. Unpredictable

  3. 567

  4. 0

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

The variable k is declared but never initialized. In C++, reading an uninitialized local variable results in undefined behavior - the output will be whatever garbage value happens to be in that memory location. This is unpredictable and can vary between runs. Option B (Unpredictable) correctly identifies this behavior. Note that the header has a typo: 'iosteam.h' should be 'iostream.h', but the conceptual question about uninitialized variables is still valid.