Exit | Result



Exit | Result
Smart pascal source code
function MyFunc(i : Integer) : Integer; begin if i<=0 then Exit(-1) else begin Result:=i; if i=10 then Exit(i+1) else if i>10 then Exit(Result+2) end; end; function MyFunc2(i : Integer) : Integer; begin if i<=0 then exit -1 else begin Result:=i; if i<10 then exit else if i=10 then exit i+1 else if i>10 then exit Result+2 end; end; {------ main.pas ------} Begin WriteLn(MyFunc(0)); WriteLn(MyFunc(5)); WriteLn(MyFunc(10)); WriteLn(MyFunc(11)); { <<< CONSOLE OUTPUTS >>> -1 5 11 13 } WriteLn(MyFunc2(0)); WriteLn(MyFunc2(5)); WriteLn(MyFunc2(10)); WriteLn(MyFunc2(11)); { <<< CONSOLE OUTPUTS >>> -1 5 11 13 }