Answer to Question #14764 in C# for Miths

Question #14764
A program to identify whether the number entered by a user is even or odd?
1
Expert's answer
2012-09-14T10:14:07-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS