diff --git a/C++/opp sign.cpp b/C++/opp sign.cpp new file mode 100644 index 0000000..6019db1 --- /dev/null +++ b/C++/opp sign.cpp @@ -0,0 +1,18 @@ +// C++ Program to Detect if two integers have opposite signs. +#include +using namespace std; + +bool oppositeSigns(int x, int y) +{ + return ((x ^ y) < 0); +} + +int main() +{ + int x = 100, y = -100; + if (oppositeSigns(x, y) == true) + cout << "Signs are opposite"; + else + cout << "Signs are not opposite"; + return 0; +}