2021 PO R1 Question Paper Eng
2021 PO R1 Question Paper Eng
Question 1 – Determinant
Test your program with the following cases:
Give your answer as a number only with no spaces, e.g.
Kevin, a university student, is struggling with his
1234
mathematics homework and can’t find his calculator.
Help him find the correct answers for the following
mathematical operation. 1a) 4 -2 6 3
Given as input 4 space-separated integers a b c d, write 1b) 6 7 7 7
a program to output the value ad – bc. The value of each
integer is between -10000 and 10000. 1c) 78 21 43 65
1d) 9999 -400 173 77
Example: 4 5 2 3
Answer: 2 (4*3 – 5*2)
Question 3 – Carpet
Question 2 – Sum of Series
Aladdin has decided that being a prince is overrated, and
Write a program to determine the sum of the first n so has opened an online carpet shop.
terms of the following series: In Aladdin's shop the price of a carpet depends on the
length of the carpet and the number of different colours
used. In his computer system, a carpet is represented by
1/2 + 2/3 + 3/4 + 4/5 + 5/6 + …, where n is between 1
a string of letters, e.g., zbbcbbx, where each character
and 10000. Output the answer rounded off to 2 decimal
represents the colour of a fixed stretch of carpet. Note
places.
that the total length of the string would be the same as
Note: A value between 0.005 and 0.009 rounds off to the total length of the carpet. Ultimately, the price of a
0.01, while a value between 0.001 and 0.004 rounds off carpet is the length of the carpet multiplied by the
to 0.00. For this question only, your program does not number of different colours used.
have to do the rounding; you may round off by hand.
Write a program that, when given a string representing
Example: n = 4 a carpet, outputs its price.
Answer: 2.72 (rounded off from 2.716666)
Example: abacx
Answer: 20 (length 5 multiplied by 4 different types)