Can you help me to check a number is even or odd without using any conditions.

Can't!!
Your question has words "OR" this means you've to use a branched code...

Can you help me to check a number is even or odd without using any conditions.

I think Bitwise & operator can be useful.

No & 2 == 0 means Odd
and
No & 2 == 2 means Even
(here No is any number)

Is this correct?

I think it also using condition but different approach rather than modulus

I think Bitwise & operator can be useful.

No & 2 == 0 means Odd
and
No & 2 == 2 means Even
(here No is any number)

Is this correct?

I think it also using condition but different approach rather than modulus

Though zero isn't an even number, it's even enough.

No & 2 == 2 would return false for No = 0.

.
.
.

Modulus wins!

Though zero isn't an even number, it's even enough.

No & 2 == 2 would return false for No = 0.


Modulus wins!

Yes, I agree
but you can change the condition like

No & 1 == 1 means Odd

otherwise Even

commented: Yes, the bitwise AND will always return true when comparing an odd number with 1 since 1 bitAND 1 is true (or 1) +3

}
Console.WriteLine("enter number to check even or odd");
int n=Convert.ToInt32(Console.ReadLine);
string []array=new string[]{"Even","Odd"};
Console.WriteLine(n%2);
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.