Вы находитесь на странице: 1из 1

One member of this group asked a program to comare 2 variables without using relational operators.

Here i am sending the code,so that it might be useful for all. concept used: 1: simple if statement ,which evaluates true block if the result of the conditio n becomes non-zero. 2: X-OR Gate & Negation. #include void main() { int a=12; int b=14; if(a/b) if(!(a^b)) printf("Both are equal"); else printf("a is big"); else printf("b is big now!!!!!!!"); } Feature: ===== This works for 2 different integers as well as 2 equal numbers Limitation: ======= I think it won't work correctly for negative numbers.

Вам также может понравиться