1. Write the pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and 25).
2. Write pseudocode that will perform the following:
a) Read the marks of three subjects: Computer
Science, Mathematics and Physics, out of 100
b) Calculate the aggregate marks
c) Calculate the percentage of marks
3. Write an algorithm to find the greatest among two different numbers entered by the user.
4. Write an algorithm that accepts four numbers as input and find the largest and smallest of them.
Answers
Explanation:
Curious why you feel 1 is a multiple of 5.
Pseudocode can mean a few things. It can mean “write in this specific syntax of pseudocode that you are being taught”, or it can just mean “write in a way that doesn’t necessarily use any particular programming language, but makes the algorithm clear”.
Here’s few ways:
set i=0
while i * 5 <= 100
i = i + 1
print i * 5
or
set i = 1
while i < 21
print i * 5
i = i + 1
or
set i=0
while i <= 100
i = i + 5
print i
or
for i = 1 .. 100 step 5
print i
or
foreach i in 1 to 100
if (i % 5 == 0)
print i
or
print "5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100"
or… but I’m hoping you’ve figured out at least some algorithm by now
Answer:
2.Step1: READ num1
Step2: READ num2
Step3:IF (num1 > num2)
PRINT num1
ELSE
PRINT num2
Step4: END