In the program segment shown in Fig. 4.9, x, y, and answer are real variables, and n

Question:

In the program segment shown in Fig. 4.9, x, y, and answer are real variables, and n is an integer variable. Prior to execution of this while loop, the user supplies real values for x and y and a nonnegative integer value for n. Prove (by mathematical induction) that for all x, y ˆˆ R, if the program reaches the top of the while loop with n ˆˆ N, after the loop is bypassed (for n = 0) or the two loop instructions are executed n (> 0) times, then the value assigned to answer is x + ny.
In the program segment shown in Fig. 4.9, x, y,

Figure 4.9

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: