From 15265ab8aa94fdf1dc5bcfe1cb198ba6a4beb415 Mon Sep 17 00:00:00 2001 From: umarulfarook <92313292+umarulfarook@users.noreply.github.com> Date: Fri, 15 Oct 2021 09:13:01 +0530 Subject: [PATCH] Create opp sign.cpp --- C++/opp sign.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 C++/opp sign.cpp 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; +}