*/
Love this site? Hate it? Leave us some comments.
*/

View \IFDEMO.PAS

Getting Started with the Pascal tutorial, source

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 4 - Program 2 *)
program Demonstrate_Conditional_Branching;

var One,Two,Three  : integer;

begin  (* main program *)
   One := 1;           (* these are to have some numbers *)
   Two := 2;           (* to use for illustrations *)
   Three := 3;

   if Three = (One + Two) then        (* Example 1 *)
      Writeln('three is equal to one plus two');

   if Three = 3 then begin            (* Example 2 *)
      Write('three is ');
      Write('equal to ');
      Write('one plus two');
      Writeln;
   end;

   if Two = 2 then                    (* Example 3 *)
      Writeln('two is equal to 2 as expected')
   else
      Writeln('two is not equal to 2... rather strange');

   if Two = 2 then                    (* Example 4 *)
      if One = 1 then
         Writeln('one is equal to one')
      else
         Writeln('one is not equal to one')
   else
      if Three = 3 then
         Writeln('three is equal to three')
      else
         Writeln('three is not equal to three');

end(* main program *)

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.