Introduction to the Pascal Programming Language

© 1998 by Dr. Thomas W. MacFarland -- All Rights Reserved


     Instructions:   Review the following program and see if you can 
                     predict the outcome by completing a "pencil 
                     trace" of the code.  

                     Program output is provided at the end of this 
                     page.

     Compiler:       The program was prepared using Standard Pascal 
                     on a UNIX-based host computer.


% cat PASCAL/intro_pencil-16.p
{ Introduction to the Pascal Programming Language
  Dr. Thomas W. MacFarland
  intro_pencil-16.p       
}

{ The purpose of this program is to:

  1.  Demonstrate the char variable.

  2.  Demonstrate how an integer can be represented as a 
      char variable.
}

program Demonstrate_the_Char_Variable;

var Char_1, Char_2, Char_3  : char;

begin

   Char_1 := 'D';
   Char_2 := 'O';
   Char_3 := '9';

   write(Char_1, Char_2, Char_3); write('   ');
   write(Char_2, Char_3, Char_1); write('   ');
   write(Char_3, Char_1, Char_2); write('   '); writeln;

end.  { intro_pencil-16.p      } 
% pc PASCAL/intro_pencil-16.p
% a.out
DO9   O9D   9DO   

Please send comments or suggestions to Dr. Thomas W. MacFarland

There have been visitors to this page since February 1, 1999.