Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.

Similar presentations


Presentation on theme: "Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false."— Presentation transcript:

1 Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false. Compound expressions are created with the operators and, or, not. Since interlocking expressions –e g: a>b>c—are not allowed in Pascal. So, Boolean expressions are combined to accomplish the same end result. continue...

2 Pascal Programming And... Expects this and that condition will both be met for the statement to be true. Or...Expects that one or both conditions will be met for the statement to be true. Not... Changes true to false and false to true. Precedence affects these operators– they are settled (1) not, (2) and (3) or. continue...

3 Pascal Programming An expression with and yields true only when both are true. If one or both conditions are false it yields false. An expression with or yields true unless both conditions are false. An expression with not yields true when the expression is not(true). The Turbo compiler uses short-circuit evaluation—evaluating only as many conditions as may be needed to determine the value.

4 Pascal Programming Using Sets... A Boolean can evaluate a set. Syntax...Ans in [‘A’, ‘B’] –in is a reserved word. A Set contains a list of constants separated by commas and enclosed in square brackets. The set may be used as a sub-part of a Boolean expression. (Not precedes the expression.)

5 Pascal Programming A variable can contain a Boolean expression but it must be type Boolean. Variables with type Boolean are declared just like other variables. A function can return a type Boolean. This can make it read more like natural language.

6 Pascal Programming Multiway branching can be accomplished with nested if-then-else statements... e g : if N > 25 then If O > than 5 then –........ or Case statements. continue...

7 Pascal Programming Syntax... (The Label List follows the of.) –Case Grade of ‘A’, ‘B’: writeln(‘Very Good!’); “C”: writeln (‘Passing’); ‘D’, ‘F’: writeln (‘Too bad!’); else Writeln(‘No Grade was posted.’) End Case statements can be controlled by types integer or char but not real or string. The else can be omitted with an effect similar to omitting it on the if-then-else statement.


Download ppt "Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false."

Similar presentations


Ads by Google