Below figure is the flow-chart corresponding to a program to calculate the gcd…

PYQ GATE 1988

Below figure is the flow-chart corresponding to a program to calculate the gcd of two integers, M and N respectively, (M, N >0). Use assertions at the cut point C₁, C₂ and C₃ to prove that the flow-chart is correct.

Flowchart initializes L=M and K=N; at cut C1 it tests K≠L; equality reaches cut C3 and returns K. On inequality it tests K>L, subtracts L from K when true or K from L when false, joins at cut C2 and loops to C1.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…