Even Odd in Every Language
Published on 01 November 2018 (Updated: 02 May 2020)
In this article, we’ll tackle the even/odd project, its requirements, and how to test each solution.
Description
An even number is an integer which is “evenly divisible” by two. This means that if the integer is divided by 2, it yields no remainder.
An odd number is an integer which is not evenly divisible by two. This means that if the integer is divided by 2, it yields a remainder of 1.
Requirements
Create a file called “Even Odd” using the naming convention appropriate for your language of choice.
Write a sample program which accepts an integer on the command line and outputs if the integer is Even or Odd.
Testing
The following table contains various test cases that you can use to verify the correctness of your solution:
Description | Input | Output |
---|---|---|
no input | None | Usage: please input a number |
empty input | ”” | Usage: please input a number |
invalid input: not a number | a | Usage: please input a number |
sample input: even | 2 | Even |
sample input: odd | 5 | Odd |
sample input: negative even | -14 | Even |
sample input: negative odd | -27 | Odd |
Articles
-
Even Odd in C on 05 October 2020 by Shubhra Gupta
-
Even Odd in Python on 16 October 2019 by Mandy Mericle
Further Reading
- Fill out as needed