Pascal error: until expected else found -
fatal error while trying compile "until" expected found "else", cant seem how fix it
......
begin divisor:= 2; cont:= 0; write(i,':'); repeat if (i mod divisor = 0) begin write(' divisor '); divisor:=succ(divisor); cont:=succ(cont); end; else divisor:=succ(divisor); until (cont = 6) or (divisor>i div 2) writeln(); end; end; end.
the issue have semicolon after end;
before else
. terminates if
statement else
becomes else
repeat
(which isn't valid). fix remove semicolon after end;
see reference: http://wiki.freepascal.org/else
fix:
if (i mod divisor = 0) begin write(' divisor '); cont:=succ(cont); end else divisor:=succ(divisor);
Comments
Post a Comment