Answer to Question #17761 in C++ for apoorva

Question #17761
write a function that takes two int arguments and returns reference of the odd number out of two.If both the arguments are odd,then the reference of the smaller one is returned. dont use printf n cin.getline .
1
Expert's answer
2012-11-02T10:11:23-0400

int& func(int& first, int& second)
{
if(first & 1 && second & 1)
return first>second?first:second;
else if(first & 1)
return first;
else if(second & 1)
return second;
else
return first>second?first:second;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS