Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions C++/opp sign.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// C++ Program to Detect if two integers have opposite signs.
#include<iostream>
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;
}