Detect if two integers have opposite signs | C ++ Program to Detect if two integers have opposite signs . ; Function to detect signs ; Driver Code
#include <stdbool.h> NEW_LINE #include <stdio.h> NEW_LINE bool oppositeSigns ( int x , int y ) { return ( ( x ^ y ) < 0 ) ; } int main ( ) { int x = 100 , y = -100 ; if ( oppositeSigns ( x , y ) == true ) printf ( " Signs ▁ are ▁ opposite " ) ; else printf ( " Signs ▁ are ▁ not ▁ opposite " ) ; return 0 ; }