Algorithm, Pseudocode and Flochart
Algorithm, Pseudocode and Flochart
pseudocode
Algorithm and pseudocode
Algorithm: Provides a high-level description of the steps to solve a particular
problem.
Pseudocode: A more detailed yet still simplified version of the algorithm,
showing how you might write it in a way that is close to actual programming
code.
Combination of programming language and natural language.
Activity 1
Write an algorithm for the sum of any two numbers?
Activity 2
Write an algorithm for the difference of any two numbers?
Activity 3
Write an algorithm for the sum of any three numbers?
Activity 4
Write an algorithm and pseudocode for the quotient of any two
numbers?
Algorithm and pseudocode
• Start • Start
• Input the numbers x, y • Input x, y
• Compute the quotient, z=x/y • Z=x/y
• If y is not equal to 0 • If y <> 0
• Print z • Print z
• Else • Else
• Print “undefined!” • Print “undefined!”
• End • Endif
• End
Activity 5
Write an algorithm for the area of a rectangle?
Example
Algorithm Pseudocode
1. Start Start
2. Input: Read/Input the two numbers, x and y Input a
3. Process: Compute the sum of x and y. Input b
Let the result be sum = x + y sum = a + b
4. Output: Display the result, sum Output sum
5. End End
Activity 6
Write an algorithm and pseudocode for the difference of any two
numbers?
Draw a flowchart.
Activity 7
Write an algorithm and pseudocode that can find area of a circle?
Draw a flowchart.
conditional statements (like if, else if, and else)
OUTPUT "How many cakes do you need to make?" IF eggs < 1 THEN
INPUT numberCakes OUTPUT "You will need 1 egg"
flour = 10 * numberCakes ELSEIF eggs < 2 THEN
sugar = 10 * numberCakes OUTPUT "You will need 2 eggs"
butter = 2 * numberCakes ELSE
eggs = 0.1 * numberCakes OUTPUT "You will need 3 eggs"
OUTPUT "You will need" & flour & "grams of flour" ENDIF
OUTPUT "You will need" & butter & "grams of
butter"
OUTPUT "You will need" & sugar & "grams of
sugar"
Cont…
A user enters their score and the program tells the user whether they are in first, second or
third place, or not placed in this contest.
FOR count = 1 TO 10
OUTPUT count
NEXT count
Activity 2
Print Numbers from 10 to 1