72.3k views
3 votes
A local variable is printed outside its function. What is the output?

O A global version of the variable
O Both local and global versions of the variable
O The local variable
OThe output is not defined

User Dan Head
by
5.1k points

2 Answers

2 votes
O The output is not defined
User Rajeev Ranjan
by
4.8k points
6 votes

Answer:

O The output is not defined

Step-by-step explanation:

A proper compiler won't allow the print statement to compile. It cannot be executed.

Assuming the program does compile somehow, the print statement would reference a memory location whose value may or may not have any relationship with the last stored value of the local variable.

The output is not defined.

User Jeewon
by
5.4k points