Algorithms+and+Pseudocode

Algorithms
An [|algorithm] is a series of steps required to solve a problem.

For example, an algorithm for baking a cake might be:



We use algorithms in this way to help design the steps of a computer program.

Pseudocode
[|Pseudocode] is an outline of a program written in a way that it can be easily converted into a computer programming language.

Questions
The algorithms below have been written using pseudocode. Can you say what each does?

Program 1
1. set yes_votes to 89 2. set no_votes to to 16 3. total_votes = yes_votes + no_votes 4. display total_votes

Program 2
1. ask user for juice_cost_price 2. ask user for juice_sale_price 3. ask user for cans_sold 4. unit_profit = juice_sale_price - juice_cost_price 5. total_profit = unit_profit x cans_sold 6. display total_profit

Program 3
1. ask user for age 2. if age >= 65 then 3. display "Pensioner, ticket price = £4.50" 4. else if age >= 18 then 5. display "Adult, ticket price = £7.50" 6. else 7. display "Child, ticket price = £3.50"

Program 4
1. repeat 10 times 2. display "Hello World" 3. end repeat