Python
Python
2 i←1 start
3 while i ≤ 100 do
4 print i
5 i←i+1
i=1
6 end
7end
while i ≤ 100
do
No
Yes
print i
i←i+1
end
output
2.Design a algorithm that prints all numbers divisible by 5 and 7 between
1 and 100
Pseudocode
1begin
2 i←1
5 print i
6 end
7 i← i +1
8 end
9end
flowchart
start
i←1
A
A
While i<100 do
No
Yes
Yes
Print i
i←i+1
End
Output
3.Design a algorithm that when given a set S=[12,22,33,44,55] prints all
elements in S
Pseudocode
1begin
4 print Si
5 end
6 end
Flowchart:
start
print Si
end
Output
4.Design a algorithm that when given a set S=[12,22,33,44,55] determines the sum
of the elements in S
Pseudocode
1begin
3 size←|S|
4 sum←0
6 sum ← sum + Si
7 end
8 Print sum
9End
Flowchart
start
size←|S|
sum←0
A
A
Sum ←sum + Si
Print sum
End
Output
5.Design a algorithm that checks whether the number 1121 is prime or not and
prints ‘It is Prime’.
Pseudocode:
1begin
2 n←1121
3 i←2
4 while i<n do
7 end
8 i←i+1
9 end
11 end
Flowchart:
start
n←1121
i←2
A
A
while i<n do
Yes
end
No
i←i+1
Output