Q4 in Activity 2.1

38 views
Skip to first unread message

Kaushik Chandrasekhar

unread,
Oct 25, 2020, 11:19:53 PM10/25/20
to Discussion forum for Computational Thinking
Dear Team, 

Just had a doubt in this question, as count does not get reassigned to zero after every iteration, the answer should be 10, considering there are 10 cards that match the criteria. My understanding is that "count" can take the value 1 (that is card found) if count is reassigned to 0 after every iteration.

Kindly clarify 

Laxmi Priya Kasi

unread,
Oct 26, 2020, 12:47:46 AM10/26/20
to Discussion forum for Computational Thinking, Kaushik Chandrasekhar
Same doubt. Please Clarify

Computational Thinking Support 2

unread,
Oct 26, 2020, 6:29:33 AM10/26/20
to Discussion forum for Computational Thinking, Laxmi Priya Kasi, Kaushik Chandrasekhar
There are 10 cards that satisfy the condition for the "Correct card". The variable found becomes true right after the first "correct card" is encountered. Along with setting found to true, the variable count is incremented by 1. The moment found becomes true, the iteration terminates. So at the end of the execution, the variable count stores the value 1.

Regards,
Karthik

Laxmi Priya Kasi

unread,
Oct 26, 2020, 10:38:57 PM10/26/20
to Discussion forum for Computational Thinking, ct-su...@onlinedegree.iitm.ac.in, Laxmi Priya Kasi, Kaushik Chandrasekhar
Clear sir. Thank you!
Reply all
Reply to author
Forward
0 new messages