Bounded
For Loops
Write an algorithm to accept the prices of 5 items and print the total cost.
Header: Price_of_items
Declaration: The purpose of this algorithm is to calculate the total cost of the five items.
Variables: cost of real, total, i = integer
Step 1: Start
Step 2: Set total cost <- 1
Step 3: For i = 1 to 5 do
5i. Write (Please enter costs of number)
5ii. Read Cost
5iii. Set total <- total + cost
Endfor
Step 4: Print (‘The total cost is, total’)
Step 5: Stop
Unbounded Loops- where we
While Loop- write an algorithm to accept a set of numbers and calculate the total. The
program should terminate when the number 999 is entered