# Check a number is even or odd without using arithmetic operators

Here given code implementation process.

// C Program
// Check a number is even or odd without using arithmetic operators
#include <stdio.h>
// Determine whether given number is Even or Odd
void checkEvenOdd(int num)
{
// Display given number
printf("\n Number : %d",num);

if((num & 1 ) == 0 )
{
// When last bit is not set
printf("\n Is Even Number \n");
}
else
{
printf("\n Is Odd Number\n");
}
}
int main(int argc, char const *argv[])
{

// Test Cases
// 12 (1100)
checkEvenOdd(12);
// 34 (100010)
checkEvenOdd(34);
// -12 (∞11110100)
checkEvenOdd(-12);
// 7 (111)
checkEvenOdd(7);
// 21 (00010101)
checkEvenOdd(21);
// -11 (11110101)
checkEvenOdd(-11);
return 0;
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
/*
Java Program
Check a number is even or odd without using arithmetic operators
*/
public class Comparison
{
// Determine whether given number is Even or Odd
public void checkEvenOdd(int num)
{
// Display given number
System.out.print("\n Number : " + num );
if ((num & 1) == 0)
{
// When last bit is not set
System.out.print("\n Is Even Number \n");
}
else
{
System.out.print("\n Is Odd Number\n");
}
}
public static void main(String[] args)
{
Comparison task = new Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
// Include header file
#include <iostream>
using namespace std;
/*
C++ Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
public:
// Determine whether given number is Even or Odd
void checkEvenOdd(int num)
{
// Display given number
cout << "\n Number : " << num;
if ((num &1) == 0)
{
// When last bit is not set
cout << "\n Is Even Number \n";
}
else
{
cout << "\n Is Odd Number\n";
}
}
};
int main()
{
Comparison task = Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
return 0;
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
// Include namespace system
using System;
/*
C# Program
Check a number is even or odd without using arithmetic operators
*/
public class Comparison
{
// Determine whether given number is Even or Odd
public void checkEvenOdd(int num)
{
// Display given number
Console.Write("\n Number : " + num);
if ((num & 1) == 0)
{
// When last bit is not set
Console.Write("\n Is Even Number \n");
}
else
{
Console.Write("\n Is Odd Number\n");
}
}
public static void Main(String[] args)
{
Comparison task = new Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
<?php
/*
Php Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
// Determine whether given number is Even or Odd
public	function checkEvenOdd(\$num)
{
// Display given number
echo "\n Number : ". \$num;
if ((\$num & 1) == 0)
{
// When last bit is not set
echo "\n Is Even Number \n";
}
else
{
echo "\n Is Odd Number\n";
}
}
}

function main()
{
\$task = new Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
main();

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
/*
Node Js Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
// Determine whether given number is Even or Odd
checkEvenOdd(num)
{
// Display given number
process.stdout.write("\n Number : " + num);
if ((num & 1) == 0)
{
// When last bit is not set
process.stdout.write("\n Is Even Number \n");
}
else
{
process.stdout.write("\n Is Odd Number\n");
}
}
}

function main()
{
var task = new Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
main();

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
#   Python 3 Program
#   Check a number is even or odd without using arithmetic operators

class Comparison :
#  Determine whether given number is Even or Odd
def checkEvenOdd(self, num) :
#  Display given number
print("\n Number : ", num, end = "")
if ((num & 1) == 0) :
#  When last bit is not set
print("\n Is Even Number ")
else :
print("\n Is Odd Number")

def main() :
#  Test Cases
#  12 (1100)
#  34 (100010)
#  -12 (∞11110100)
#  7 (111)
#  21 (00010101)
#  -11 (11110101)

if __name__ == "__main__": main()

#### Output

Number :  12
Is Even Number

Number :  34
Is Even Number

Number :  -12
Is Even Number

Number :  7
Is Odd Number

Number :  21
Is Odd Number

Number :  -11
Is Odd Number
#   Ruby Program
#   Check a number is even or odd without using arithmetic operators

class Comparison
#  Determine whether given number is Even or Odd
def checkEvenOdd(num)
#  Display given number
print("\n Number : ", num)
if ((num & 1) == 0)
#  When last bit is not set
print("\n Is Even Number \n")
else
print("\n Is Odd Number\n")
end

end

end

def main()
#  Test Cases
#  12 (1100)
#  34 (100010)
#  -12 (∞11110100)
#  7 (111)
#  21 (00010101)
#  -11 (11110101)
end

main()

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
/*
Scala Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
// Determine whether given number is Even or Odd
def checkEvenOdd(num: Int): Unit = {
// Display given number
print("\n Number : " + num);
if ((num & 1) == 0)
{
// When last bit is not set
print("\n Is Even Number \n");
}
else
{
print("\n Is Odd Number\n");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var task: Comparison = new Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
/*
Swift 4 Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
// Determine whether given number is Even or Odd
func checkEvenOdd(_ num: Int)
{
// Display given number
print("\n Number : ", num, terminator: "");
if ((num & 1) == 0)
{
// When last bit is not set
print("\n Is Even Number ");
}
else
{
print("\n Is Odd Number");
}
}
}
func main()
{
let task: Comparison = Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}
main();

#### Output

Number :  12
Is Even Number

Number :  34
Is Even Number

Number :  -12
Is Even Number

Number :  7
Is Odd Number

Number :  21
Is Odd Number

Number :  -11
Is Odd Number
/*
Kotlin Program
Check a number is even or odd without using arithmetic operators
*/
class Comparison
{
// Determine whether given number is Even or Odd
fun checkEvenOdd(num: Int): Unit
{
// Display given number
print("\n Number : " + num);
if ((num and 1) == 0)
{
// When last bit is not set
print("\n Is Even Number \n");
}
else
{
print("\n Is Odd Number\n");
}
}
}
fun main(args: Array < String > ): Unit
{
var task: Comparison = Comparison();
// Test Cases
// 12 (1100)
// 34 (100010)
// -12 (∞11110100)
// 7 (111)
// 21 (00010101)
// -11 (11110101)
}

#### Output

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number
// Rust Program
// Check a number is even or odd without using arithmetic operators
fn main()
{
// Test Cases
// 12 (1100)
check_even_odd(12);
// 34 (100010)
check_even_odd(34);
// -12 (∞11110100)
check_even_odd(-12);
// 7 (111)
check_even_odd(7);
// 21 (00010101)
check_even_odd(21);
// -11 (11110101)
check_even_odd(-11);
}
// Determine whether given number is Even or Odd
fn check_even_odd(num: i32)
{
// Display given number
print!("\n Number : {}", num);
if (num & 1) == 0
{
// When last bit is not set
print!("\n Is Even Number \n");
}
else
{
print!("\n Is Odd Number\n");
}
}

Number : 12
Is Even Number

Number : 34
Is Even Number

Number : -12
Is Even Number

Number : 7
Is Odd Number

Number : 21
Is Odd Number

Number : -11
Is Odd Number

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.