And or Not Statements
 

THE AND OR NOT STATEMENTS
The AND, OR and NOT keywords are used where you want to execute a block of code (or statement) when more than one condition is necessary.

  AND   The statement is executed only if BOTH conditions are true,

if (A = 1) AND (B = 2) then writeln('Bingo!');

OR The statement is executed if EITHER argument is true,

if (A = 1) OR (B = 2) then writeln('Hurray!');

NOT Converts TRUE to FALSE and vsvs

if NOT ((A = 1) AND (B = 2)) then writeln('Wow, really heavy man!');




CLASS EXERCISE
What is displayed after the following program is executed?

program AND_OR_NOT_DEMO (output);
var a, b, c : integer;
begin
a := 5; b := 3; c := 99;
if (a = 5) or (b > 2) then writeln('A');
if (a < 5) and (b > 2) then writeln('B');
if (a = 5) and (b = 2) then writeln('C');
if (c <> 6) or (b > 10) then writeln('D') else writeln('E');
if (b = 3) and (c = 99) then writeln('F');
if (a = 1) or (b = 2) then writeln('G');
if not( (a < 5) and (b > 2)) then writeln('H')
end.

Class Exercise .. Output of program AND_OR_NOT_DEMO is,
A
D
F
H

(c) Shilpa Sayura Foundation 2006-2017