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;
 


SELF TEST
Are the following valid variable declarations?


var day, month : integer;
time : real;

var time : real;
day : integer;
month: integer;


Classify each of the following according to the four basic data types.
	34.276   ____________         -37   __________________

H ____________ < __________________

dd ____________ 5.09E+27 _______________

0 ____________ 0.0 __________________

 
 
Answers
 
Are the following valid variable declarations? 

var day, month : integer;
time : real;

var time : real;
day : integer;
month: integer;

They are both identical and also valid!


Classify each of the following according to the four basic data types.
	34.276  Real         -37       Integer
H Character < Character
dd Character 5.09E+27 Real
0 Integer 0.0 Real

(c) Shilpa Sayura Foundation 2006-2017