0

I wrote a programm, but there is an error that i can't understand.

Error: main.pas(23,11) Fatal: Syntax error, ")" expected but "ordinal const" found

program Hello; <-- 10 line
var 

x : integer;
y : integer;


begin


for x := 0 to 120 do

    begin
                                <-- error line
        if ( x % 5 = 0 ) then
            writeln (x);
    
    end;

  
end. <-- 30 line
George
  • 47
  • 1
  • 8
  • `x % 5 = 0` is the error. You probably want to use the modulo operator. `%` is the modulo operator in c and other languages. In pascal the modulo operator is `mod`. That is `x mod 5 = 0`. – LU RD Nov 26 '20 at 11:49
  • @LURD Thanks, it worked. You can write it in answers – George Nov 26 '20 at 11:59

1 Answers1

1

x % 5 = 0 is the error.

You probably want to use the modulo operator.

% is the modulo operator in c and other languages. In pascal the modulo operator is mod.

The correct statement would then be:

if (x mod 5 = 0) then WriteLn(x);
LU RD
  • 34,438
  • 5
  • 88
  • 296