Test for an Even or Odd Value

image_pdfimage_print

   
 
using System;
using System.Data;


class Class1{
        static void Main(string[] args){
           Console.WriteLine(IsEven(0));
           Console.WriteLine(IsEven(3));
           Console.WriteLine(IsOdd(2));
           Console.WriteLine(IsOdd(1));

        }
    public static bool IsEven(int intValue)
    {
      return ((intValue & 1) == 0);
    }

    public static bool IsOdd(int intValue)
    {
      return ((intValue & 1) == 1);
    }
}


           
         
     


This entry was posted in Data Types. Bookmark the permalink.