This C# Program checks if a given integer is Odd or Even. Here if a given number is divisible by 2 with the remainder 0 then the number is an Even number. If the number is not divisible by 2 then that number will be an Odd number.
class Program
{
static void Main(string[] args)
{
int i;
Console.Write("Enter a
Number : ");
i = int.Parse(Console.ReadLine());
if (i % 2 == 0)
{
Console.Write("Entered Number is an Even Number");
Console.Read();
}
else
{
Console.Write("Entered Number is an Odd Number");
Console.Read();
}
}
}
0 comments:
Post a Comment