Q:

Java Program to Detect if two integers have opposite signs

0

Java Program to Detect if two integers have opposite signs

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class GFG {
    static boolean oppositeSigns(int x, int y)
    {
        return ((x ^ y) < 0);
    }    
    public static void main(String[] args)
    {
        int x = 100, y = -100;
        if (oppositeSigns(x, y) == true)
            System.out.println("Signs are opposite");
        else
            System.out.println("Signs are not opposite");
    }
}
// This code is contributed by prerna saini.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now