Ask Question
21 August, 18:06

This exercise contains a while loop and a predicate. loop: while (m ≥ 0 and m ≤ 100) m : = m + 4 n : = n - 2 end while predicate: m + n is odd Fill in the blanks to show that if the predicate is true before entry to the loop, then it is also true after exit from the loop. Suppose m + n is odd before entry into the loop. Suppose m + n is odd before entry into the loop. Let new + new denote the values of m and n after exit from the loop. Find and simplify an expression for new + new in terms of m and n.

+4
Answers (1)
  1. 21 August, 19:48
    0
    m' + n' = m + n + 2

    Step-by-step explanation:

    We are told that m + n is odd before entry into the loop. So let, P (q) be m + n is even on qth iteration of the while loop

    Our basis step will be q = 0.

    So, let P (k) be true and we can say that m + n is odd on the kth iteration of the while loop

    Now, we need to prove that P (k + 1) is true.

    Thus, on the (k + 1) th iteration, m is increased by 4 and n is decreased by 2.

    Let's call the new values m' and n'.

    So, m' = m + 4 and n' = n - 2

    Thus, m' + n' = m + 4 + n - 2 = m + n + 2
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “This exercise contains a while loop and a predicate. loop: while (m ≥ 0 and m ≤ 100) m : = m + 4 n : = n - 2 end while predicate: m + n is ...” in 📙 Mathematics if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers