Download presentation
Presentation is loading. Please wait.
Published byMelina Payne Modified over 9 years ago
1
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include: –if statements –case statements
2
Pascal Programming Today Chapter 4 2 If-then-else Statements Syntax of if-then-else statements if then else May be a Boolean constant, Boolean variable or Boolean expression.
3
Pascal Programming Today Chapter 4 3 If-then-else Statements Syntax of if-then-else statements if then else Will be executed if is TRUE.
4
Pascal Programming Today Chapter 4 4 If-then-else Statements Syntax of if-then-else statements if then else Will be executed if is FALSE.
5
Pascal Programming Today Chapter 4 5 Flowchart of an if-then-else statement
6
Pascal Programming Today Chapter 4 6 »Sometimes, more than one statement is required to be executed under the condition. »In such case, a compound statement should be used.
7
Pascal Programming Today Chapter 4 7 »A compound statement consists of two or more simple statements enclosed by a pair of reserved words begin and end.
8
Pascal Programming Today Chapter 4 8 Syntax of if-then-else statements with compound statements if then begin ; end else begin ; end Compound statement
9
Pascal Programming Today Chapter 4 9 Flowchart of an if- then-else statement with compound statements
10
Pascal Programming Today Chapter 4 10 If-then Statements Syntax of if-then statements if then
11
Pascal Programming Today Chapter 4 11 Flowchart of an if-then statement
12
Pascal Programming Today Chapter 4 12 Syntax of if-then statements with compound statements if then begin ; end
13
Pascal Programming Today Chapter 4 13 Flowchart of an if-then statement with compound statement
14
Pascal Programming Today Chapter 4 14 Nested If Statements »An if statement may be nested by another if statement to form a nested if statement.
15
Pascal Programming Today Chapter 4 15 Syntax of nested if statements if then if then else else if then else
16
Pascal Programming Today Chapter 4 16 Flowchart of a nested if statement
17
Pascal Programming Today Chapter 4 17 »Reserved word else should be matched to the nearest preceding if in nested if statements.
18
Pascal Programming Today Chapter 4 18 Case Statements »A case statement is preferred for selection involving more than three alternatives.
19
Pascal Programming Today Chapter 4 19 Syntax of case statements case of : ; : end A variable or an expression of ordinal data types ( integer, char or Boolean ).
20
Pascal Programming Today Chapter 4 20 Syntax of case statements case of : ; : end Lists of possible values of.
21
Pascal Programming Today Chapter 4 21 Syntax of case statements case of : ; : end Simple or compound statements.
22
Pascal Programming Today Chapter 4 22 »Only one selection on the list of statements will be executed. »No statements will be executed if no case label match the selector.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.