0

I'm new in Pascal and I don't know how a fix this error: Incompatible types: got "S80REAL" expected "LONGINT"

My code is:

Var
number1:Integer;
a,b:Integer;
a,i:Integer;

procedure number(number1: Integer);
begin
a:=1;
b:=number1+(number1-1);
  for a:=1 to number1 do
  begin
    for i:=1 to ((b-a)/2) do
    begin
    write('#');
    end;
  end;
end;

Error is here: for i:=1 to ((b-a)/2) do

Thank you for help.

1 Answer 1

3

Replace the '/' ( (b-a)/2 ) with 'div'

'/' is real division in Pascal, 'div' is integer division

procedure number(number1: Integer);
begin
 a:=1;
 b:=number1 + number1 - 1;
 for a:=1 to number1 do
  begin
   for i:=1 to ((b-a) div 2) do
    begin
     write('#');
    end;
  end;
end;
Sign up to request clarification or add additional context in comments.

2 Comments

+1 And have a look at trunc/round if you want more control about rounding.
@NejcGalof: Please 'accept' my answer if you found it useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.