0
How to write this condition?
i want to write it in code... condition is " if given number is divisible by two". eg: if(condition) { cout{ //statement} else {//statement}
2 Réponses
+ 7
if (number % 2 == 0)
+ 1
You use the “modulus” operator (%), which divides by two and returns the remainder of the division. Then you check that there is no remainder, indicating that the number was evenly divisable by two
((number % 2) == 0)