Ask Question
4 September, 19:58

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.

+3
Answers (1)
  1. 4 September, 22:49
    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?
Find 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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers