Gate CS-2015-1 Question Paper With Solutions

Q. 43 Consider the following pseudo code, where x and y are positive integers.

begin
   q := 0
   r := x
while r >= y do
   begin
      r := r – y
      q := q + 1
   end
end

The post condition that needs to be satisfied after the program terminates is

(A) {r = qx + y ∧ r < y}

(B) {x = qy + r ∧ r < y}

(C) {y = qx + r ∧ 0 < r < y}

(D) { q + 1 0}

Answer: (B)

Explanation:

Gate CS-2015-1 Question Paper With Solutions

Learn More:   Gate EE-2014-3 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here