Challenge: Even or Odd

In this exercise, you are required to check whether the number is Even or Odd.

Problem Statement #

Write a code which will check whether a given integer $number is even or odd. You’re given a variable $temp set this to 0 if the $number is even and 1 if the $number is odd.

Hint: Think along the lines of using if-else condition.

Input #

an integer

Output #

boolean 0 if number is even and 1 if number is odd

Sample Input #

$number = 3

Sample Output #

1

Coding Exercise #

Write your code below. It is recommended that you try solving the exercise yourself before looking at the solution.

Good Luck!

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy