Consider the following PASCAL program segment: if i mod 2 = 0 then while i >=…

PYQ GATE 1991Modified — slightly modified from the official paper; see the solution

Consider the following PASCAL program segment:

if i mod 2 = 0 then

while i >= 0 do

begin

i:=i div 2;

if i mod 2 <> 0 then i:=i - 1

else i:=i - 2

end

An appropriate loop-invariant for the while-loop is ______

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…