Sunday 20 December 2015

Check odd even number in c# program example

This is how we could check odd and even number in console application.


using System;
namespace calc
{
    class checkodd
    {
        int a = 3;
        public void check()
        {
            if (a % 2 == 0)
            {
                Console.WriteLine(a + " is an even number");
            }
            else
            {
                Console.WriteLine(a + " is an odd number");
            }
        }
        public static void Main()
        {
            checkodd obj = new checkodd();
            obj.check();
            Console.ReadLine();
        }
    }
}