0

can you say to me, where is the error. I wanna write in console the content of the a[i] in every for run. The output could be 6 digits. There is compiler Alert:

/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?

...Program finished with exit code 0

program Hello;

type aha = array [1..6] of integer;

var 
a: aha;
n,x,i: integer;

begin
a[1]:=2;
a[2]:=6;
a[3]:=4;
a[4]:=2;
a[5]:=4;
a[6]:=3;

n:=6;

x:=a[1];

for i:=2 to n do
begin
{
  if (a[i-1]>= x) then
  begin
  a[i]:=a[i] - x div 2;
  end;
  
  else 
  begin
  a[i]:=a[i] + x;
  x:= x + mod x(a[i] + 1);
  end;
  
  writeln (a[i]);
}
end;
end.
  • 1
    I don't know what the suggested "-T" option means for the compiler, but I know that the pair of braces "{" and "}" makes it treat everything in between as a comment. Remove them. Possibly also add a `readln:` immediately before the `end.` to keep the console window open . – Tom Brunberg Jan 17 '21 at 22:46
  • 1
    Also, remove the semicolon (;) before `else`. It is an error as the `if condition then begin ... end else begin ...end;` is a compound statement. You have an error in the line ` x:= x + mod x(a[i] + 1);` You can not have a `+` operator immediately followed by a `mod` operator. – Tom Brunberg Jan 17 '21 at 23:34
  • 1
    You can ignore the -T warning. It is due to a migration aspect in some linux distros – Marco van de Voort Jan 18 '21 at 15:01

0 Answers0