Professional Documents
Culture Documents
Algorithms
Algorithms
ALGORITHM
SAMPLE 1
Read num1
Read num2
Sum=num1+num2
Display sum
SAMPLE 2
Average=(score1+score2+score3)/3
Display average
SAMPLE 3
Max=4
4<3 max=4
4<8 max=8
8<6 max=8
8<2 max=8
Max=8-largest element
Sample 4
a1=1
a2=22
a3=3
a4=4
an=5
For i=5 to 1
Display ai
Properties of algorithm
1. Input
2. Output
3. Correctness
4. Finiteness
5. Effectiveness
Selection Statement
• If condition then
Statement1
Else
Staement2
Display “Excellent”
ELSE
Repetition(Loop)
Statement/s
For m=1 to 5
Display “LPU”
SEARCHING ALGORITHM
4,7,3,2,1,0,9
SEATWORK:
Write the pseudocode of the following:
1. Display numbers one to ten together with your name
1 John
2 John
3 John
.
.
10 John
2. Display the summation of numbers1, 2,3,4,and 5 using a loop.