Consider the following pseudo code, where \(x\) and \(y\) are positive…

GATE · 2015 · CS · Set 1 · Computer Science & IT

Consider the following pseudo code, where xx and yy 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

  1. A.

    {r=qx+y∧r<y}\{ r = qx + y \wedge r < y\}

  2. B.

    {x=qy+r∧r<y}\{ x = qy + r \wedge r < y\}

  3. C.

    {y=qx+r∧0<r<y}\{ y = qx + r \wedge 0 < r < y\}

  4. D.

    {q+1<r−y∧y>0}\{ q + 1 < r - y \wedge y > 0\}

Attempted by 383 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…