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; } } }
Comments
Leave a comment