Professional Documents
Culture Documents
Development
Conditional Statements
Conditional Statements
Conditional statements allow the
computer to compare variables
and select one of two
alternatives or decide whether to
repeat an instruction or set of
instructions.
Types of Conditional
Statement
There are two main types of Conditional Statements:
1. Selection: the presentation of a condition, and the
choice between two or more actions, depending on
whether the condition is true or false.
RELATIONAL
LOGICAL
ARITHMETIC OPERATORS
Print “Enter
grade”
Read grade
F Print
Grade >
59 “Fail”
T
Print
“Pass”
STOP
Class Work
Write an algorithm to prompt for and accept the
cost of an item. If the cost is greater than
$200 the customer is entitled to a 20%
discount. Output the cost
Class Work
Write an algorithm to prompt for and accept the cost of
an item. If the cost is greater than $200 the customer
is entitled to a 20% discount. Output the cost
Solution:
START
Var cost, NewPrice, Discount
Print “The cost of an item”
Read cost
If cost > 200 THEN
Discount = cost * 0.2
NewPrice = cost – Discount
Print “The cost of the item is “, NewPrice
Else
Write “The cost of the item is “, Cost
End If
STOP