0% found this document useful (0 votes)
5 views1 page

Calculate Total Cost of Items Algorithm

The document outlines two algorithms: one for calculating the total cost of five items using a bounded for loop, and another for summing a set of numbers using an unbounded while loop that terminates when the number 999 is entered. The first algorithm initializes a total cost variable, prompts for item prices, and computes the total. The second algorithm continuously accepts numbers until the sentinel value of 999 is inputted to stop the process.

Uploaded by

Daivya Jagmohan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Calculate Total Cost of Items Algorithm

The document outlines two algorithms: one for calculating the total cost of five items using a bounded for loop, and another for summing a set of numbers using an unbounded while loop that terminates when the number 999 is entered. The first algorithm initializes a total cost variable, prompts for item prices, and computes the total. The second algorithm continuously accepts numbers until the sentinel value of 999 is inputted to stop the process.

Uploaded by

Daivya Jagmohan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like