0

What is the meaning of the following code? I have asked my questions in code bit in the form of comments .

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

14th Oct 2021, 2:56 PM
King
King - avatar
3 Réponses
+ 3
If statement excutes when the condition is true In your code y%z is 0 it means false That's why if statement doesn't excute and else statement does You can test by changing the value of z to 5 so,y%z =1 and the condition of the if statement becomes true then the output will be 4
14th Oct 2021, 3:08 PM
Myo Thuzar
Myo Thuzar - avatar
+ 2
6%3 = 0 (no remainder) 0 evaluates to false, as the condition is false, the else-part is printed
14th Oct 2021, 3:08 PM
Lisa
Lisa - avatar
+ 2
Truth value of 0 is false. And otherthan 0 is treated as true so y%z determines truthvalue value there. cout<<--x; pre decrement condition so first value is decreased then printed cout<<x--; post decrement condition so first value is used or printed then after decreased. For more details, se pre/post increment/decrement operators.. Hope it helps..
14th Oct 2021, 3:14 PM
Jayakrishna 🇮🇳