Since Pascal ignores end-of-lines and spaces, punctuation is needed to tell the compiler when a statement ends.
You MUST have a semicolon following:
Indenting is not required. However, it is of great use for the
programmer, since it helps to make the program clearer. If you
wanted to, you could have a program look like this:
     program Stupid; const a=5; b=385.3; var alpha,beta:real; begin alpha := a + b; beta:= b / a end.
But it's much better for it to look like this:
program Stupid; const a = 5; b = 385.3; var alpha, beta : real; begin (* main *) alpha := a + b; beta := b / a end. (* main *)
In general, indent two to four spaces for each block. Skip a line between blocks (such as between the const and var blocks).
Most importantly, use comments liberally! If you ever return to a program that you wrote ten years ago, you probably wouldn't remember the logic unless you documented it. It is a good idea to comment the main executable part of the program, to distinguish it from subprograms.
![]() Previous lesson |
![]() To assignment |
![]() Contents |
![]() Index |
![]() e-mail me |