Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

bitwise even or odd

// C# program to check for even or odd
// using Bitwise AND operator
using System;
 
class GFG
{
     
    // Returns true if n is even, else odd
    static bool isEven(int n)
    {
        // n&1 is 1, then odd, else even
        return ((n & 1) != 1);
    }
         
    // Driver code
    public static void Main()
    {
        int n = 101;
        Console.Write(isEven(n) == true ? "Even" : "Odd");
    }
}
 
// This code is contributed by AnkitRai01
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #bitwise #odd
ADD COMMENT
Topic
Name
5+9 =