0
What is the meaning of the following code? I have asked my questions in code bit in the form of comments .
3 Antworten
+ 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
+ 2
6%3 = 0 (no remainder)
0 evaluates to false, as the condition is false, the else-part is printed
+ 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..