The issue is really clear, if you learn to properly indent (format) your code. This answer is based on the original code you posted, before you added more and removed some to change it. The information in the answer is still relevant to the problem, however.
What you posted:
Program Arrayexamp(output); Var counter,index,input: Integer; A : Array[1..15] of Integer;
begin
For index := 1 to 15 do
begin read(input);
A[index] := input;
index++
end;
begin
For index := 1 to 15 do
If (counter mod 2 = 0) Then B[counter]=A[counter]*3 Else B[counter]=A[counter]-5; end.
How it looks properly formatted:
Program Arrayexamp(output);
Var
counter,index,input: Integer;
A : Array[1..15] of Integer;
begin
For index := 1 to 15 do
begin
read(input);
A[index] := input;
index++
end;
begin
For index := 1 to 15 do
If (counter mod 2 = 0) Then
B[counter] = A[counter] * 3
Else B[counter]=A[counter]-5;
end.
The problem is clear: You have a begin
without a matching end;
in the lower block. In fact, the begin
is totally unnecessary, and can be removed.
The second problem is that the for
loop itself will increase the loop variable, so it's illegal to modify that counter inside the loop. Remove the index++;
line. (See the next paragraph, too.)
A third problem is that Pascal does not support pre-increment or post-increment operators, so index++
is invalid syntax. Use index := index + 1;
or Inc(index);
instead.
The code written more properly:
Program Arrayexamp(output);
Var
counter,index,input: Integer;
A: Array[1..15] of Integer;
begin
For index := 1 to 15 do
begin
read(input);
A[index] := input;
end;
For index := 1 to 15 do
if (counter mod 2 = 0) Then
B[counter] = A[counter] * 3
Else B[counter]=A[counter] - 5;
end.
For more information regarding the syntax and use of begin..end
in Pascal, see this answer I wrote for Proper structure syntax for Pascal if then begin end