← All examples

Solving a linear equation

Pascal Branching

if / else if / else

Flowchart (ISO 5807)

YesNoYesNoStartInput a, ba <> 0Output -b / ab = 0Output «безліч розв»«язків»Output «немає розв»«язків»EndFigure 1 — solveLinear

Source code

procedure solveLinear(a, b: real);
begin
  if a <> 0 then
    writeln(-b / a)
  else if b = 0 then
    writeln('безліч розв''язків')
  else
    writeln('немає розв''язків');
end;