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
Differentiate between the = symbol and == symbol?
Can you please explain the difference between syntax vs logical error?
List the difference between a "copy constructor" and a "assignment operator"?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What is substring in c?
What is the best way to comment out a section of code that contains comments?
What are the types of pointers in c?
How do I swap bytes?
explain what is fifo?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
Tell me the use of bit field in c language?
Is exit(status) truly equivalent to returning the same status from main?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What are pointers? What are different types of pointers?
Explain the use of bit fieild.