Using Pascal VARIABLES in a program
The basic format for declaring variables is,


	var name : type;	
where name is the name of the variable being declared, and type is one of the recognised data types for pascal.
Before any variables are used, they are declared (made known to the program). This occurs after the program heading, and before the keyword begin, eg,

	program VARIABLESINTRO (output);
	   var  number1: integer;
	        number2: integer;
	        number3: integer;
	begin
	        number1 := 34;  { this makes number1 equal to 34 }
	        number2 := 43;  { this makes number2 equal to 43 }
	        number3 := number1 + number2;
	        writeln( number1, ' + ', number2, ' =  ', number3 )
	end.

The above program declares three integers, number1, number2 and number3.

To declare a variable, first write the variable name, followed by a colon, then the variable type (int real etc). Variables of the same type can be declared on the same line, ie, the declaration of the three integers in the previous program


	 var number1: integer;
	     number2: integer;
	     number3:integer;

could've been declared as follows,

	 var number1, number2, number3 : integer;

Each variable is seperated by a comma, the colon signifies there is no more variable names, then follows the data type to which the variables belong, and finally the trusty semi-colon to mark the end of the line.
Some example of variable declarations

	program VARIABLESINTRO2 (output);
	   var  number1: integer;
	        letter : char;
	        money  : real;
	begin
	        number1 := 34;
	        letter  := 'Z';
		money   := 32.345;
	        writeln( "number1 is ", number1 );
		writeln( "letter is  ", letter );
		writeln( "money is   ", money )
	end.


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.