GitHub Repository Submission

When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more

Your GitHub repository URL is saved. LSBot will automatically fetch your latest code from this repository for each message. To change the URL, clear it first and save a new one.

Exercise 11

Using the code from Exercise 9, are the left and right variables on lines 1 and 2 the same as the left and right variables on lines 10-12? Explain your reasoning.

Solution

They are not the same variables.

The left and right variables declared on lines 10 and 11 are a little tricky. First, though they have the same names as the parameters defined for the multiply function, they are not the same variables. (The function parameters shadow the variables on lines 10 and 11.) Furthermore, they are global variables even though they are only accessible on line 12 (technically, left is also accessible on line 11 but is not used). They are considered global because they are defined at the topmost level of the program.

The left and right parameters on line 1 are local variables since function parameters are always local to the function. Thus, line 2 refers to the local variables.

Video Walkthrough

Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...

Submit your solution for LSBot review.

Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...