Greatest of Two Numbers Without Using A Relational Operator

Posted by ratty on Stack Overflow See other posts from Stack Overflow or by ratty
Published on 2010-04-09T10:50:09Z Indexed on 2010/04/09 11:03 UTC
Read the original article Hit count: 271

Filed under:
|
|

I want to find the greater of two numbers without using < > this relational operator. I tried this

int a,b;
if(a/b==0)
{
b is greater
}
else
{
a is greater
}

but this not working for negative numbers.

© Stack Overflow or respective owner

Related posts about c

    Related posts about comparison