Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   puzzle in C (http://www.go4expert.com/forums/puzzle-in-c-t19510/)

vignesh1988i 22Sep2009 17:54

puzzle in C
 
PUZZLE IN C!!!!!

write a C/C++ program to say whether a one number is equal to another or not without using RELATIONAL OPERATORS and ARTHMETIC OPERATORS????????:)

SaswatPadhi 22Sep2009 19:15

Re: puzzle in C
 
That's simple.

A [XOR] B = 0 if A == B
A [XOR] B != 0 if A != B

Code: C

if(A^B) {printf("%d != %d\n",A,B);}
else      {printf("%d == %d\n",A,B);}


vignesh1988i 23Sep2009 08:13

Re: puzzle in C
 
ya... you are right..... good keep it up!!!!!!


All times are GMT +5.5. The time now is 09:54.