Python
1.Design a algorithm that prints integers from 1 to 100
Pseudo code flowchart
1begin
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
3 while i < 100 do
4 if i mod 5 =0 & i mod 7=0 then
5 print i
6 end
7 i← i +1
8 end
9end
flowchart
start
i←1
A
A
While i<100 do
No
Yes
if i % 7==0 and i % 5==0
then
No
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
2 S←{12, 22, 33, 44, 55}
3 For i←1 to size(S) do
4 print Si
5 end
6 end
Flowchart:
start
S←{12, 22, 33, 44, 55}
For i←1 to size(S)
do
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
2 S←{12, 22, 33, 44, 55}
3 size←|S|
4 sum←0
5 for i←1 to size do
6 sum ← sum + Si
7 end
8 Print sum
9End
Flowchart
start
S←{12, 22, 33, 44, 55}
size←|S|
sum←0
A
A
For i←1 to size do
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
5 if n mod i==0 then
6 print “it is not a prime”
7 end
8 i←i+1
9 end
10 print ”it is prime”
11 end
Flowchart:
start
n←1121
i←2
A
A
while i<n do
print ”it is prime”
No
Yes
end
if n mod i==0 then
Yes Print ” it is not a
prime”
No
i←i+1
Output