Ask coding questions

← Back to all posts
how can I tell the compiler a number is odd or even ?
Donbit

Write a conditional statement that evaluates whether the value for a number property is odd or even. If the number is even, print "The number is even", otherwise, print "The number is odd".

Voters
rioholland
Johnevenjohn
Donbit
Comments
hotnewtop
ronniegertman

in many langueges use the following steps:
for example java:
int num;
if (num%2==0)
System.out.println("even");
else
System.out.println("odd");