Learn Pascal Programming with Mc Kenzie IF Selection Statement The general format of an IF statement is : IF condition THEN statement. The statement will be executed only if the condition is true. If the condition is not true then the statement which follows the word THEN will not be executed.
|
|
Program 7 This program asks the user to enter a single number which the program will place in the memory location A. Output will be displayed only if the user enters a number greater than 100.
Program 7 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 Compare. The heading ends with the first semi-colon after (input, output) which tells us that the program expects user input before it produces output on screen. 2. The declaration section begins with Var followed by an integer variable a then a colon before the word INTEGER. 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. Test Yourself The example above demonstrates a simple IF statement. There are compound IF statements as well where more than one statement is executed if the condition is true. Revise what you have learnt before moving on to compound if statements. BSS Main | Previous Lesson | Revise Lesson |
InfoDAM Web Technologies©MMX |