This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 The Boolean Data Type • This data type allows us to represent something as either True or False. • Syntax: Const flag = True; Var Variable_Name : Boolean • Example: Var Flag: Boolean Flag := True Writeln(Flag) (* will give as output True *) 2 Relational Operators Simple Boolean Expressions • Operators used for comparison are called “Relational Operators”, Examples: =, >, <, <=, >=, <> • A Boolean expression is an expression that takes a Boolean value (True / False) • Example – comparing two numbers or variables if they are equal • Note: Only data of the same type can be compared. 3 Relational OperatorsBoolean Expressions (Priorities) • Note: operand1<>operand2 allows you to test if operand1 is different from operand2. 4 =, >, <, <=, >=, <> 3 +,  2 / , *, Div, Mod 1 ( ) Priority Operator 4 Relational OperatorsBoolean Expressions • A Boolean Expression can be assigned to a Boolean Variable. • Example: Var falg: Boolean; anInt: Integer; anInt := 10; Falg := (anInt>5);(*Flag has a boolean value True because anInt 10 is greater than 5*) 5 Logical Operator ANDOR Compound Expressions • Used to connect two Boolean expressions, thus composing one single expression. • Example: ( 3 > 2) And ( 5 > 4) (* True And True gives True *) ( 3 >2) Or (3 <2) (* True Or False gives True *) • When AND is used to join two expressions, the resulting compound expression is True only if both expressions are True. 6 Logical Operators ANDOR The NOT operator • When an Or operator is used to join two expressions, the resulting compound expression is FALSE only if both expressions are FALSE. expressions are FALSE....
View
Full
Document
This note was uploaded on 11/04/2009 for the course SSE CSC 1400 taught by Professor Mhamdi during the Spring '09 term at Al Akhawayn University.
 Spring '09
 Mhamdi

Click to edit the document details