I'm using Borland Turbo Pascal ver. 6.0 and it seems that the book I'm using to program with (I'm a beginner) is not compatible with the program. I have copied programs word for word out of the book and, when I try to run or compile, the TP interpretter gives me an error message saying "Begin needed", when in fact the program is perfect according to the book. I've tried this numerous times and either my programming style or the compiler/interpretter are seriously hindering the completion and application of my programs. What can I do to fix this?
Here is one of programs I copied word-for-word out of the book I'm using for those of you who enquired:
program Sine; (Input, Output);
const
Pi = 3.14159
MinAngle = 0
MaxAngle = 360
var
Theta, X : Real
Work : Char
begin
WriteLn ('Hello.');
begin
X := 180
Theta = Sin(X)
end
WriteLn (Theta);
end.
Well, in THIS program, there are two errors:
- After the program name (Sine) and the IO, there sould not be
a semicolon. The first line should be something like:
program Sine(input,output);
Anyway, I think that in TP 6.0 you don't need the IO, and
program Sine;
would be enough.
This is the place where the compiler says "BEGIN excepted".
- After any statement, includnig the CONST part, you sould put
semicolon:
Pi = 3.141592;
and so on in the VAR and in the program itself.
One more thing about this program: there is a logical-block with no need - between the two WRITELN.
Now ,to your question: What should you do...
That easy. You should do two things:
1. Get yourself a GOOD book that has programs WITHOUT bugs...
2. Get yourself a newer version of TP.