Page 126 - Computer Science V2.0 Class 11
P. 126
Ans. input csMarks, mathsMarks, physicsMarks
averageMarks ← (csMarks + mathsMarks + physicsMarks) / 3
percentageMarks ← ((csMarks + mathsMarks + physicsMarks) / 300) * 100
print averageMarks
print percentageMarks
8. Write an algorithm to find the greatest among two different numbers entered by the user.
Ans. input num1, num2
if num1 >= num2 then
print num1
else
print num2
9. Write an algorithm that performs the following:
Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write
the word BLUE. if the number is between 25 and 35, write the word ORANGE. If it is any other number, write that ALL COLOURS ARE
BEAUTIFUL.
Ans. input num
if num >=5 AND num < 15 then
print "GREEN"
else if num >= 15 AND num < 25 then
print "BLUE"
else if num >= 25 AND num < 35 THEN
print "ORANGE"
else
print "ALL COLOURS ARE BEAUTIFUL"
10. Write an algorithm that accepts four numbers as input and find the largest and smallest of them.
Ans. input num1, num2, num3, num4
min ← num1, max ← num1
if num2 < min then
min ← num2
if num3 < min then
min ← num3
if num4 < min then
min ← num4
if num2 > max then
max ← num2
if num3 > max then
max ← num3
if num4 > max then
max ← num4
print "minimum=", min
print "maximum=", max
11. Write an algorithm to display the total water bill charges of the month depending upon the number of units consumed by the customer
as per the following criteria:
for the first 100 units @ 5 per unit
for next 150 units @ 10 per unit
more than 250 units @ 20 per unit
Also add meter charges of 75 per month to calculate the total water bill .
Ans. input unitsConsumed
first100Rate ← 5
112 Touchpad Computer Science (Ver. 2.0)-XI

