Monday 28 September 2015

Write a console program to check Odd, Even Number

This is how, where we could write simple console program to check either input number is Even or Odd. But first of all we are going to share the flow of basic program in numeric steps.

       

          
//1. call existing namespace
//2. create class
//3. create input veriables
//4. create functions
//5. create Main method
//6. Inside Main method, create new object of class
//6. Call object.function()
//7. Console.Read()


using System; 
 
public class FindOddEven 
{
    public int a = 20;

    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()
    {
        FindOddEven obj = new FindOddEven();
        obj.check();

        Console.Read();
    }


}