NTA (UGC)-NET: Major Variables Types
An integer is a signed or unsigned whole number. Valid characters in an integer are the digits 0 − 9 and the + sign and the-sign. The largest and smallest values that can be assigned to a variable of type integer are dependent upon the computer system being used. Pascal has a standard identifier named maxim whose value is the largest integer a particular system is capable of storing. Therefore, the range of integers that can be stored in any particular system is:
The data type real is used to store real numbers. This includes any number containing a decimal points within the allowable range of your system. The range of real numbers that a particular system can store is always much greater than the range of integers. You may want to consult your computer system's technical reference manual to determine the exact range of allowable real numbers on your system.
In Pascal, there are two possible representations for real numbers. The first method decimal notation, requires that a real number contain at least one digit before and one after the decimal point. This is the form in which we most commonly write real numbers.
The second method is exponential notation. The numbers is written as a value (the mantissa) which is multiplied by 10 (represented by E) to the appropriate power (the characteristic). The decimal point in the mantissa is optional, but on most systems the mantissa must be a value between 1.000 and 9.999. The resulting number, however, will always be of data type real. The characteristic, indicates the power to which 10 is raised (that is, the number of places the decimal point is moved) and must always be of data type integer. A plus sign ( + ) or no sign preceding the characteristic indicates that the decimal point is to be shifted to the right a certain number of places, and a negative sign (-) indicates that the decimal point should be shifted a certain number of places to the left. With both signs, zeros are inserted where necessary.
The real number 4630.0 is represented in exponential notation with each element of the number labeled.
Variables of data type Boolean can represent only one of the two values: True; or false. For Example, if a variable named Continue was of type boolean, it could only be equal to either true or false. This data type is named after George Boole, an English mathematician who invented a system of logic using only the values true and false. Boolean variables are sometimes referred to as logical variables.
Understanding boolean data types, may require some extra thought. It may help to think of a boolean variable as a switch. The switch is either on or off. Boolean variables are often used as “flags” to control execution of paths of programs.
The data type char (short for character) contains all of the characters that can be represented by a given computer system; this is referred to as the character set of that particular system. This includes not only all of the characters on the keyboard, but also other characters that cannot be printed. This character set will vary, depending on your system. A variable of type char can contain only a single character at a time. The character must be enclosed in single quotation marks when it is included in a program statement. If it is not enclosed in quotes, the computer will not be able to distinguish in from a variable name. For example ‘X’ tells the compiler that this is a character value, whereas the compiler would see X as a variable name. However, only the character, and not the quotation marks, are stored in the computer. The following are example of char values:
Note that the number 8 in quotes will be treated as a character and not a number; this means that it cannot be used in any mathematical operation such as addition or subtraction.
A Pascal program has three distinct sections: a program heading, a declaration section, and a program body.
The program heading provides a name for the entire program and consists of the reserved identifier program followed by any valid used-defined identifier. This is the name of the program.
In addition to assigning a program name, the program heading may also contain a list of the external files to be used by the program. External files exist beyond the duration of the program and are usually located on a secondary storage medium such as a magnetic disk. Pascal provides two standard files, named input and output. These two files refer to the standard input and output devices for a particular system. In most instances, the input device is the keyboard, although it may also be a disk drive or some other input device. In many systems, the output device will be the terminal screen, although it may be printer or another output device.
Check with your instructor for specific information regarding your system. The program heading always concludes with a semicolon. Below are some valid program headings:
program Inventory (input, output)
program Project (input, output)