find a number whether it is even or odd without using any
control structures and relational operators?
Answer Posted / ramya
A number anded with the lower number that is n & (n - 1) =
0 then it is even if it is anything else it is odd
odd_even (int n)
{
if (!(n & (n -1))
number is odd
else
number is even
}
| Is This Answer Correct ? | 9 Yes | 29 No |
Post New Answer View All Answers
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What is structure and union in c?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
How do I swap bytes?
What is the most efficient way to count the number of bits which are set in an integer?
What is meant by inheritance?
Why use int main instead of void main?
Discuss the function of conditional operator, size of operator and comma operator with examples.
When should I declare a function?
I came across some code that puts a (void) cast before each call to printf. Why?
What is c language and why we use it?
Explain what are linked list?
What does char * * argv mean in c?
What does. int *x[](); means ?
I need testPalindrome and removeSpace
#include