Learn Pascal Programming with Mc Kenzie Assigning Values To assign a numeric value to a variable after the variable has been declared we use the colon followed by the equal sign without a space as follows x := 6;
|
Real Numbers Real numbers carry a decimal point. 20 is an integer but 20.0 is real. Here is another example : 0.6 is a valid real number in Pascal but .6 alone without the zero before the point is not valid. Before we can use a real variable in the body of a Pascal program, we must declare it. Program Sample1 demonstrates how two real variables are declared and used in a program.
The Sample1 program is made up of three sections: 1. The Program Heading starts with the word PROGRAM followed by the name of the program. The name of this program is Sample1 .The heading ends with the first semi-colon. 2. The declaration section begins with Var followed by a list of three variables x, y, result then a colon before the word REAL. The last character on the line is the semi-colon. 3. The body of the progarm starts with the word begin and terminates with the word end. BSS Main | Previous Lesson | Next Lesson |
InfoDAM Web Technologies©MMX |