A Collection of Code Snippets in as Many Programming Languages as Possible

This project is maintained by TheRenegadeCoder

Welcome to the Even Odd page! Here, you'll find a description of the project as well as a list of sample programs written in various languages.

This article was written by:

- Jeremy Grifski

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.

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.

Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Even Odd. In order to keep things simple, we split up the testing as follows:

- Even Odd Valid Tests
- Even Odd Invalid Tests

Description | Input | Output |
---|---|---|

Sample Input: Even | "2" | "Even" |

Sample Input: Odd | "5" | "Odd" |

Sample Input: Negative Even | "-14" | "Even" |

Sample Input: Negative Odd | "-27" | "Odd" |

Description | Input |
---|---|

No Input | |

Empty Input | "" |

Invalid Input: Not A Number | "a" |

All of these tests should output the following:

```
Usage: please input a number
```

- Even Odd in Algol68
- Even Odd in Bash
- Even Odd in Beef
- Even Odd in C
- Even Odd in C#
- Even Odd in C++
- Even Odd in Cobol
- Even Odd in Coffeescript
- Even Odd in Commodore Basic
- Even Odd in Dart
- Even Odd in Elixir
- Even Odd in Euphoria
- Even Odd in Fortran
- Even Odd in Go
- Even Odd in Groovy
- Even Odd in Haskell
- Even Odd in Java
- Even Odd in Javascript
- Even Odd in Julia
- Even Odd in Kotlin
- Even Odd in Lisp
- Even Odd in Lua
- Even Odd in Mathematica
- Even Odd in Objective C
- Even Odd in Octave
- Even Odd in Odin
- Even Odd in Pascal
- Even Odd in Perl
- Even Odd in Php
- Even Odd in Pyret
- Even Odd in Python
- Even Odd in R
- Even Odd in Rexx
- Even Odd in Ruby
- Even Odd in Rust
- Even Odd in Scala
- Even Odd in Swift
- Even Odd in Typescript
- Even Odd in X86 64