Challenge 1: Even or Odd
Let's check whether the number is Even or Odd by solving a challenge in this lesson.
We'll cover the following...
We'll cover the following...
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 the number is even, and 1 if the 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!