Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Differentiate between the = symbol and == symbol?

1209


Can you please explain the difference between syntax vs logical error?

1134


List the difference between a "copy constructor" and a "assignment operator"?

958


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

1085


What is substring in c?

1132


What is the best way to comment out a section of code that contains comments?

1263


What are the types of pointers in c?

972


How do I swap bytes?

1023


explain what is fifo?

1027


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

2204


Tell me the use of bit field in c language?

1016


Is exit(status) truly equivalent to returning the same status from main?

1008


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

997


What are pointers? What are different types of pointers?

1058


Explain the use of bit fieild.

1097