Problem: Even or Odd
Write a program that checks whether an integer is even or odd.
Sample Input and Output
Input | Output |
---|---|
2 | even |
3 | odd |
25 | odd |
1024 | even |
Hints and Guidelines
Again, first we add a new C# console project in the existing solution. In the static void Main ()
method, we have to write the program code. Checking if a given number is even can be done with the operator %
, which will return the remainder from an integer divided by 2 as follows: var isEven = (num % 2 == 0)
.
Now we run the program with [Ctrl + F5] and test it:
Testing in the Judge System
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/506#2.