Is a Number Even?


 
   ///////////////////////////////
   // wyatt
   //    accepts an int argument
   //    checks if even by dividing by 2
   //       & checking remainder
   //    return t/f
   static bool IsEven( int x )
   {
       // check if even
       if (x % 2 == 0)
           return true;
       else
           return false;
   }
   
OR
  
   ///////////////////////////////
   // wyatt
   //    accepts an int argument
   //    checks if even by dividing by 2
   //       & checking remainder
   //    return t/f   
   static bool IsEven( int x )
   {
       // check if even by checking the remainder
       if (x % 2 == 0)
           return true;
       return false;
   }   
OR
   
   ///////////////////////////////
   // wyatt
   //    accepts an int argument
   //    checks if even by 'anding' with 1
   //    return t/f
   static bool IsEven( int x )
   {
       // check if even by using the AND logical operation
       if (x && 1 == 0)
           return true;
       return false;       
   }         
   
 
*************** OVERLOADED
   
   ///////////////////////////////
   // wyatt
   //    accepts a decimal argument
   //    checks if even dividing by 2
   //    return t/f
   static bool IsEven( decimal x )
   {
       // check if even by checking the remainder
       if (x % 2 == 0)
           return true;
       return false;    
   }         
   
 


TO CALL:
    

      // To call this method:               
      int x = 7891;
      bool even = IsEven( x ); // returns false in the variable, even
      
      // execute this code ONLY if the value of even is true
      if( even )
      {
         ...
            
OR
  

      // To call this method:               
      int x = 7891;
         
      // execute this code ONLY if the value of even is true
      if( IsEven( x ) )
      {
         ...