int i = 5;
if (i % 2 == 0)
{
// even
}
else
{
// odd
}
int num = 100;
if (num % 2 == 0){
Console.WriteLine($"{num} is an even number");
}
else if (num % 2 != 0){
Console.WriteLine($"{num} isn't an even number");
}
// wait before closing
Console.ReadKey();
if(num %2 == 0){
Console.WriteLine("Number is even")
}else{
Console.WriteLine("Number is odd")
}
// using modulo operator %
if(num%2 == 0){
Console.WriteLine("Number is even")
}else{
Console.WriteLine("Number is odd")
}
int x = 2;
if(x % 2 == 0){
Console.WriteLine("Is even");
}
else
{
Console.WriteLine("Is odd");
}
bool IsEven = ( number %2) == 0
bool IsOdd = ( number %2) == 1
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int x = 6;
if (x % 2 == 0)
{
Console.WriteLine("x is even");
} else if (x % 2 == 1)
{
Console.WriteLine("x is odd");
}
}
}
}