Pascal Programming

Pascal is a high-level language that has been used as an introductory language in high schools, colleges, and universities for the last 2 decades. It has been used in business as well. The AP Computer Science exam was given in Pascal from 1986 to 1998. Pascal is similar to C and C++ in a number of ways. At the same time, it should not be difficult for someone with knowledge of BASIC to understand Pascal.

The following keywords are important ones to know for potential ACSL contest questions:

if/then, if/then/else, case, while, repeat/until, for, real, char, integer, abs, sqr, sqrt, trunc, round, div, mod, and, or, begin, end, do, downto, function, procedure, program

Compare the following pairs of programs in order to understand the key features of Pascal.

Pascal

BASIC

x := 2; y := 10;
if x < y then
   begin
      answer := 15;
      x := x + y;
   end
else
   writeln('x is not less than y' );
x = 2
y = 10
If x < y Then
   answer = 15
   x = x + y
Else
   Print "x is not less than y"
End If
. .
Count := 1;
while (Count <= 5) do
   begin
      writeln ('not yet');
      Count := Count + 1;
   end
Count = 1
Do While Count <= 5
   Print "not yet"
   Count = Count + 1
Loop
. .
procedure WriteName(x: integer);
   var a, b: integer;
begin
   a := 2; b := 10;
   repeat
      if a < b then
         writeln('Name');
      a := a + 2;
   until (a = b);
end
Sub WriteName(x)
a = 2
b = 10
Do
   If a < b Then
      Print "Name"
   End If
   Let a = a + 2
Loop Until a = b
End Sub

 


ACSL Home Page | Mr. Minich's Wyo Home Page | Minich.com Web Design