Algorithm, Pseudo Code and The Corresponding Flowchart
Algorithm, Pseudo Code and The Corresponding Flowchart
1. Get two numbers from the user (dividend and divisor), testing to make sure that the divisor
number is not zero, and displaying their quotient.
Pseudocode: Flowchart:
Begin Step1: Start the program
Initialize dividend, divisor, quotient =0 Step2: Declare variables dividend, dividor,
OUTPUT “Enter values for dividend and quotient to 0
divisor” Step3: Print “ Enter values for dividend and
INPUT dividend, divisor divisor”
WHILE divisor = 0 Step4: Get values for dividend, divisor from
OUTPUT “Divisor must be non-zero” user
OUTPUT “Enter a value for divisor” Step5: Check if divisor=0, then
INPUT dividend, divisor Print “Divisor must be non-zer”
quotient = dividend / divisor Print “Enter a value for divisor”
OUTPUT quotient Get divisor
End Goto Step5
Else Goto Step6
Step6: Calculate,
quotient = dividend / divisor
Step7: Print quotient
Step8: Stop the program
2. Algorithm which generates even numbers between 1000 and 2000 and then prints them in the
standard output. It should also print total sum:
Pseudocode: Flowchart:
Begin Step1: Start the program
Initialize I ← 1000 and S ← 0 Step2: Declare variables I ← 1000, S ← 0
Write I Step3: Print I
WHILE (I <= 2000) Step4: WHILE( I <= 2000)
S←S+I S←S+I
I←I+2 I←I+2
Write S Print S
End Step4: Stop the program
3. Generate first 50 items of the Fibonacci series. The Fibonacci series are the numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
Prime numbers are positive integers that can only be divided evenly by 1 or themselves. By
definition, negative integers, 0, and 1 are not considered prime numbers. The list of the first few
prime numbers looks like:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, ...
For example, 5 is a prime number because you can divide 5 by 1 evenly and divide 5 by 5
without a remainder, but if you divide 5 by any other integer, you get a remainder.
5/1 = 5
5/2 = 2 plus a remainder
5/3 = 1 plus a remainder
5/4 = 1 plus a remainder
5/5 = 1
5/6 = 0 plus a remainder
... = 0 plus a remainder
4/1 = 4
4/2 = 2
4/3 = 1 plus a remainder
4/4 = 1
4/5 = 0 plus a remainder
... = 0 plus a remainder