Even or Odd Number
Even or Odd Number
Tags: Math Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes an integer and returns "Even"
if the number is even, or "Odd"
if the number is odd. This problem is designed to help you practice using if statements and modulo operations
. The function should accept one parameter and return a string indicating whether the number is even or odd.
Constraints:
- The input will be an
integer
. - The function should
return
astring
:"Even"
or"Odd"
.
Example:
- Input:
4
- Output:
"Even"
Test Case | Input | Expected Output |
---|---|---|
1 | 4 | "Even" |
2 | 7 | "Odd" |
3 | 0 | "Even" |
4 | -2 | "Even" |
5 | -3 | "Odd" |
6 | 123456789 | "Odd" |
7 | 1000000 | "Even" |
Leave a Comment
Please login to leave a comment.