So one of the questions I was confused about was about a function named displayGross(). The question asked what would happen when the computer processed the displayGross() function's return statement. I was debating between (a)"it removes the function's local variables from memory, then continues program execution with the statement immediately following the one that called the function and (b) it removes the function's local variables from memory, then continues program execution with the statement that called the function.
Another question asked about a program that contains three functions named main(), calcGross(), and displayGross (). The variable pay appears in all three functions. (declared in main() and calcGross() and in the function header of displayGross(). The question then proceeded to ask what would happen when the computer processes the statement pay = hours * rate in the calcGross() function after multiplying the hours times the rate, it would: (a) store the result in the calcGross() function's pay variable
(b) store the result in the displayGross() function's pay variable
(c) store the result in the main() function's pay variable
(d) displays an error message because you can't have three memory locations with the same name
I eliminated (d), it did not seem logical, the other choices however, perplexed me. Can someone explain why the answer is what it is in both questions?