asked 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

asked
User Dan Head
by
7.9k points

2 Answers

2 votes
O The output is not defined
answered
User Rajeev Ranjan
by
7.9k 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.

answered
User Jeewon
by
7.9k points