Question: Functions can call other functions. For example, consider the following code: define function a ( x ) = x - 1 define function b (

Functions can call other functions. For example, consider the following code:
define function a(x)= x -1
define function b(y)= a(x *3)
z := b(2)
The b(2) call is equivalent to writing out a(2*3), from the definition of program function b. Simplifying the parameter to program function a, this is equivalent to a(6). From the definition of program function a, a(6) is equivalent to 6-1. Simplifying this code down yields 5, ultimately resulting in program variable z holding the value 5.
With all this in mind, consider the following code:
define function f(x)= x +2
define function g(y)= f(y)+ f(y +1)
z := g(1)
What value will program variable z hold when the above code completes?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!