Professional Documents
Culture Documents
LBEPS Session 13
LBEPS Session 13
LBEPS Session 13
Problem Solving
Objectives
Solution:
11
6
True
3.3 Let’s Practice (Contd.)
Solution:
True
True
3.3 Let’s Practice (Contd.)
Solution:
begin
numeric nResult,n
accept n
compute nResult = n*(n-1)/n
display ‘The result of expression is ‘ + nResult
end
Conditional Execution
Compare Values
Conditional Execution
(Contd.)
The if construct:
Specifies a conditional expression that needs to be evaluated.
Is of the following types:
Simple if construct
if…else construct
Nested if…else construct
The if Construct (Contd.)
Even Odd
The if Construct (Contd.)
if <condition>
begin
<statements to be executed if condition is
true>
end
else
begin
<statements to be executed if condition is
false>
end
end
end
The if Construct (Contd.)
Discount Rates
Color Size Discount Rate
CRT - 5
LCD 14 8
LCD 21 10
The if Construct (Contd.)
Discount
The if Construct (Contd.)
Selection of
Candidates
The switch….case Construct
case constant 3:
//execute the statements within the
case //block
break
case constant 4:
//execute the statements within the
case //block
break
default:
//execute the statements within the default
//block
end
…
end
The switch….case Construct
(Contd.)
case 2:
display ‘Monday’
break
…………
…………
…………
case 7:
display ‘Saturday’
break
default:
display ‘You have entered a number
out of range’
end
end
The switch….case Construct
(Contd.)
Calculator
The switch….case Construct
(Contd.)
Call Transfer
The switch….case Construct
(Contd.)
vowel
Just a Minute
Solution:
2. break statement
Summary