Google Interview Question
Software DevelopersCountry: United States
Why not just return (i-j) in that case? It seems like this logic is more generic since some languages do not have XOR.
#include <iostream>
using namespace std;
int main()
{
int a,b;
char exit = 'n';
while( exit=='n')
{
cout << "Enter First Integer number : ";
cin >> a;
cout << "Enter second integer number :";
cin >> b;
cout<<endl;
if(!(a^b))
{
cout << "Number is equal " << endl;
}
else
{
cout << "Number is NOT equal " << endl;
}
cout << "Do you want to exit ? Y/N" << endl;
cin >>exit;
}
return 0;
}
In case the return is 0 then the numbers are equal else not equal.
- sandip.03934 August 03, 2015