Solution to Problem 10

MathJax example

See for the problem here: Click here


Correct Answer:

Code was written to verify whether 2 was identity element in \(Z_6, \oplus_6, \otimes_6\) or not. The mistake is the use of else in the first if condition , this gives an error in the answer because the final output is decided only in terms of the last iteration (in this case the output is given based on \(2\times 0=0\times 2=0\) , thus the flag value remains 1. So inorder to solve this we can modify the code as,

\(\verb|for i:1 thru n do|\)

\(\verb|if bo(z[i],e)#z[i] or bo(e,z[i])#z[i] then|\)

\(\verb|flag:1 $|\)

\(\verb|if flag=1 then|\)

\(\verb|Print(e,”is not unity element”)|\)

\(\verb|else print(e,”is the unity element “)$|\)


The above answer was given by Chaya M S (V Semester PCM, Sarada Vilas College) and ( Gagan Dev (V Semester PCM, Sarada Vilas College) in the comment section of the problem.

No comments:

Post a Comment