A program to find the greatest of two numbers

Today am going to tell you about an incident that happened
in my college. My teacher(who is now working in HCL Cisco)
told “to find the greatest of 2 numbers without using any
relational operators”.I was stunned.But later i found the
result and now i am able to realize that the answer has
something to do with LISP. Because in lisp u cant have
hand full of relational operators. But then you need to
find a solution. The solution to our home work is the
solution to the problem in LISP. Am not trying to say that
i had solved a problem in LISP. But then trying to think
in such a way that if there is a language without any
relational operators then be cool there is a remedy for it.
Though nowadays people wont accept such long challenges…

You could read the solution here:
int cmp(int a,int b)

int g=0 ;
(( ( !((b+1)/b) && (!( a/b) ) )
|| ( ((a+1)/a) && (a/b) )
) && (g=a))
|| (g=b) ;
return g;

Leave a comment

Your comment