- 1

Write an algorithm to find whether a number entered by a user is even or odd ? Hint: Even numbers are divisible by 2.

8th Mar 2017, 5:01 PM
Khulud Al-slman
Khulud Al-slman - avatar
2 Réponses
+ 6
Hint: "%" is the remainder operator.
8th Mar 2017, 5:20 PM
Álvaro
+ 2
if ((x % 2) == 0) System.out.println("Number is even"); else System.out.println("Number is odd");
8th Mar 2017, 8:58 PM
Donald Green
Donald Green - avatar