Hi,
You will not get any questions which require lengthy calculations to solve in the qualifier exam of CT.
BTW, Week 3 Q2 is not a time consuming question if you know the concept. In pseudocode, we are calculating averages of total marks (SumT), Physics marks (SumP), Maths marks (SumM) and Chemistry marks (SumC).
A = SumT/Count, B = SumM/Count, C = SumP/Count and D = SumC/Count,
You need to find, B + C + D - A = ?
Here, Sum of total marks (SumT) = Sum of Maths marks (SumM) + Sum of Physics marks (SumP) + Sum of Chemistry marks (SumC)
Now we divide by Count on both sides which will give averages of all.
So, {Sum of total marks (SumT) }/Count = {Sum of Maths marks (SumM)}/Count + {Sum of Physics marks (SumP)}/Count + {Sum of Chemistry marks (SumC)}/Count
The above expression will be,come A = B + C + D
Now bring A to right side, 0 = B + C + D - A
So the value of B + C + D - A = 0.
In the if expression we are comparing the value of
(a) (B + C + D) - A <= -1 : (0 <= -1) which not true. So value of Z will not be updated.
(b) (B + C + D) - A >= 1 : (0 >= 1) which not true. So value of Z will not be updated.
Therefore the value of Z will be 0 only.
Regards,
Deepak
IITM Online Degree Team