0

What error in this code mathematicaly answer 3 but in this code answer is 0

https://code.sololearn.com/csoLdpv0uDn4/?ref=app

25th May 2021, 8:47 AM
Ankit Kumar
Ankit Kumar - avatar
2 Answers
+ 5
What do you mean ? It's mathematically correct. Xor operator (^) is commutative ( a^b will be equal to b^a) and thus ((x^y)>(y^x)) will always evaluate to be false, and even your compiler is telling you the same.
25th May 2021, 9:09 AM
Arsenic
Arsenic - avatar
+ 4
The ^ character is the bitwise exclusive OR operator (XOR for short), which is commutative, hence the warning that a self-comparison like that always fails. https://www.sololearn.com/learn/4074/?ref=app I assume you want to compute the power instead. In that case, have a look at pow() from the standard library: https://en.cppreference.com/w/c/numeric/math/pow
25th May 2021, 9:09 AM
Shadow
Shadow - avatar