int i = 5;
if (i % 2 == 0)
{
// even
}
else
{
// odd
}
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");
}
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");
}
}
}
}