A program to identify whether the number entered by a user is even or odd?
using System;
using System.Collections.Generic;
using
System.Linq;
using System.Text;
namespace EvenOdd
{
class
Program
{
static void Main(string[] args)
{
int
number;
Console.Write("Enter number: ");
number =
int.Parse(Console.ReadLine());
if (IsOdd(number))
{
Console.WriteLine("Enter number is Odd. ");
}
if
(IsEven(number))
{
Console.WriteLine("Enter number is
Even.");
}
Console.WriteLine("Press any key to
exit....");
Console.ReadLine();
}
static bool IsOdd(int
value)
{
return value % 2 != 0;
}
static bool IsEven(int
value)
{
return value % 2 == 0;
}
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#