#if statement
24 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
If i mod 10 == 0 and i != 0
In C a expression evaluates to true if it returns a non zero value and false if it returns a zero value
so !(1 % 10) runs if the result is false cause of the ! sign. right?
@burnt sedge
Yes
The logical not (!) returns non zero if the expression its evaluating is zero and zero if the value is non zero
so it can be re-written as if (!(i == 0) && i != 0)?
No
i = 0 is assignment
And no
Thats also incorrect
Mod checks the remainder
Ie if an integer cleanly divides (0) or if doesnt (non zero)
so if i mod 10 returns any value between 1 to 9, it becmes false?
Any value thats not a multiple of 10
And yeah
but only true when i mod 10 is 0 which means theres no remainder