Consider the two program segments below: 1. for i:=1 to f(x) by 1 do S end 2.…

PYQ GATE 1988

Consider the two program segments below:

1. for i:=1 to f(x) by 1 do S end

2. i:=1; While i<=f(x) do S i:=i+1 end

Under what conditions are these two programs equivalent? Treat S as any sequence of statements and f as a function.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…