Skip to first unread message

Shubham Johri

unread,
Nov 12, 2020, 10:40:31 AM11/12/20
to Discussion forum for Computational Thinking
I don't understand why there is an error in line 20. We can take either the positive differences or negative difference of the marks. If value is 0 with positive differences, it will be 0 with negative differences as well.

SUMIT ANTIL

unread,
Nov 12, 2020, 10:46:02 AM11/12/20
to Discussion forum for Computational Thinking, Shubham Johri
Same doubt here. Can someone please clarify?

Snigdha Lele

unread,
Nov 12, 2020, 10:47:38 AM11/12/20
to Discussion forum for Computational Thinking, Shubham Johri
Yes I had the same doubt

On Thursday, November 12, 2020 at 9:10:31 PM UTC+5:30 Shubham Johri wrote:

Antony

unread,
Nov 12, 2020, 10:48:03 AM11/12/20
to Discussion forum for Computational Thinking, shubhamj...@gmail.com
The purpose of the proc is probably to return a positive value. Otherwise why to even compare C and D, you can just return c-d or d-c.

Snigdha Lele

unread,
Nov 12, 2020, 10:49:38 AM11/12/20
to Discussion forum for Computational Thinking, Antony, shubhamj...@gmail.com
No then you won't get the sum. some marks will get subtracted

Antony

unread,
Nov 12, 2020, 10:58:20 AM11/12/20
to Discussion forum for Computational Thinking, shubhamj...@gmail.com
Student1.Physics - Student2.Physics = 10
Student1.Maths - Student2.Maths = - (10)

Total diff, if you consider sign = 0 
Actual total diff = 20


On Thursday, November 12, 2020 at 9:10:31 PM UTC+5:30, Shubham Johri wrote:

Naushad C.K.

unread,
Nov 12, 2020, 10:59:38 AM11/12/20
to Discussion forum for Computational Thinking, Snigdha Lele, Antony, shubhamj...@gmail.com
As per the logic it should return positive value. The proc/func should return the differential value in positive. 

Shubham Johri

unread,
Nov 12, 2020, 12:54:25 PM11/12/20
to Discussion forum for Computational Thinking, Naushad C.K., Snigdha Lele, Antony, shubhamj...@gmail.com
There is no requirement for it to return positive value. The purpose is to check whether value=0, so whether we take positive or negative difference does not matter.

Ajay k Gupta

unread,
Nov 12, 2020, 1:33:28 PM11/12/20
to Discussion forum for Computational Thinking, Shubham Johri, Naushad C.K., Snigdha Lele, Antony
yes sir.it is never mentioned that we need value as difference ,which  needs to be postive , or it being 0 to be the method to check its equality.  the methods logic should fullfill correct requirement which is done.
also vallue isnt set to 0 in step 14 again. shouldnt it be

Shubham Johri

unread,
Nov 12, 2020, 2:39:48 PM11/12/20
to Ajay k Gupta, Discussion forum for Computational Thinking, Naushad C.K., Snigdha Lele, Antony
Value variable is being initialized with Proc2(X.Physics,Y.Physics) in the first line so it doesn't need to be set to $0$ at the end of the loop.

cheria...@gmail.com

unread,
Nov 12, 2020, 11:54:34 PM11/12/20
to Discussion forum for Computational Thinking, Shubham Johri, Discussion forum for Computational Thinking, Naushad C.K., Snigdha Lele, Antony, krishnam...@gmail.com
Line 20 need not be considered an error.

If line 20 is left as it is. Proc2 will always return only a negative value or zero.
If the sign is the opposite, Proc2 will always return only a positive value or zero.

Error in line 1 : Z=0
Error in line 10 : value = value - Proc2(X.Total,Y.Total)

Line 20 can be left as it is and the pseudo code will generate the same outcome. Therefore Line 20 need not be considered an error.

Example :

Case 1: Leave line 20 as it is :
Proc2(X.Maths,Y.Maths) = -10
Proc2(x.Physics,Y.Physics) = -20
Proc2(X.Chemistry,Y.Chemistry) = -40
Proc2(X.Total,Y.Total)= -70

Line 10 = value = -70 - (-70) = 0

Case 2: Change the comparison operator line 20 :
Proc2(X.Maths,Y.Maths) = 10
Proc2(x.Physics,Y.Physics) = 20
Proc2(X.Chemistry,Y.Chemistry) = 40
Proc2(X.Total,Y.Total)= 70

Line 10 = value = 70 - 70 = 0
Reply all
Reply to author
Forward
0 new messages