(* Pascal has what is known as reserved words - i.e. words that can not be used as identifiers *) (* the file extension you should use on your Pascal program files is .pp *) (* your program header statement must contain the default device names if you are *) (* reading from the keyboard OR writing to the screen *) (* Pascal program header statements begin with the reserved word PROGRAM *) PROGRAM identifier (input, output); VAR x, y, z : real; (* variable declaration *) i : integer; BEGIN (* := is the assignment operator in Pascal *) (* a semi-colon is a statement separator in Pascal *) x := 3.5; (* input statements are in one of three forms *) read (x); (* which gets a value from the default input device *) read (input, x); (* which gets a value from the default input device *) readln (x); (* which gets a value from the default input device and then *) (* goes to the next "line of input" *) read( x,y,z); (* which will get 3 values from the input device *) (* output statement come in one of three forms *) write (x); write (output, x:6:2); (* the :6:2 formats the output away from exponential *) (* notation *) writeln (x); (* Pascal is NOT case sensitive *) (* counted loop and a PRE-TEST loop *) FOR i := 1 TO 10 DO (* NEVER, EVER, put a semi-colon after a DO *) writeln (i); FOR i := 5 DOWNTO -1 DO BEGIN write ('hi there ! '); writeln (i); END; (* another PRE-TEST loop - you have to modify the loop control variable manually *) (* your loop should have at least 2 statements: something you want done AND the *) (* loop control variable modification *) WHILE i < 5 DO BEGIN writeln (' hello fellow '); i := i + 3; END; (* the REPEAT UNTIL loop is a POST-TEST loop *) REPEAT writeln (' class will be over soon '); i := i - 2; UNTIL i < -3 ; IF i < 4 THEN writeln (' i is less than 4 '); IF x > 0.3 THEN writeln (' x is greater than 0.3 ') ELSE writeln (' x is less than 0.3 '); (* pascal has two types of sub-programs : PROCEDURE and a FUNCTIOn *) (* Pascal has two parameter passing modes: VAR and value *) (* VAR parameters are passed by address and the word VAR has to be there *) (* value parameters are passed by being copied and are the default *) END. (* the period following the END at the end of the program is required *)