I am a 1st grade student and I got a task to complete, but cannot understand how to avoid errors that I got. Could you please help me? Here is my code:
PROGRAM LAB5MAS (INPUT,OUTPUT);
CONST
n=5;
m=6;
VAR
A: array[1..n,1..m] of Integer;
R: array[m-1] of Integer;
i,j: Integer;
max: Integer;
BEGIN
Randomize;
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(10);
Writeln('a=,');
for i:=1 to n do
BEGIN
for j:=1 to m do
write(a[i,j]:4);
writeln;
END;
for i:=1 to n do
for j:=1 to m-1 do
R[i,j]:=abs(A[i,j]-A[i,j+1]);
END.
for i:=1 to n do
BEGIN
max:=R[i,1];
for j:=1 to m-1 do
if R[i,j] > max then
max:=R[i,j];
Writeln(max);
END;
for i:=1 to n do
BEGIN
for j:=1 to m do
write(a[i,j]:4);
writeln;
END.
And the errors that I got:
Compiling C:\Users\Nadia\Desktop\qqwww\laba.pas
laba.pas(7,17) Error: Error in type definition
laba.pas(24,7) Error: Illegal qualifier
laba.pas(26,1) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
How to fix this? And how to compute the biggest value of subtraction between nearest elements in array A(5,6) and write this result to array B? Thanks in advance!
RIS DEFINED AS 1 DIMENSIN ARRAY WHILE YOU ARE USING AS MATRIXR[I,J](ALSO THE DEFINITION OFRSHOULD BEARRAY [1..M-1] OF INTEGER;Ris incorrect. Look at how you defined the valid subscripts forAin the line above. Furthermore, you are trying to useRas a two-dimensional array, when it has not been defined as such. Go back and desk-check your code.END.(ENDending with a period). That's going to be a syntax error. The syntactical end of your Pascal program is at the end of the firstEND..END.should be a separate procedure. Which Pascal dialect is this?