Check whether product of integers from a to b is positive , negative or zero | Java implementation of the approach ; Function to check whether the product of integers of the range [ a , b ] is positive , negative or zero ; If both a and b are positive then the product will be positive ; If a is negative and b is positive then the product will be zero ; If both a and b are negative then we have to find the count of integers in the range ; Total integers in the range ; If n is even then the resultant product is positive ; If n is odd then the resultant product is negative ; Driver code
import java . io . * ; class GFG { static void solve ( long a , long b ) { if ( a > 0 && b > 0 ) { System . out . println ( " Positive " ) ; } else if ( a <= 0 && b >= 0 ) { System . out . println ( " Zero " ) ; } else { long n = Math . abs ( a - b ) + 1 ; if ( n % 2 == 0 ) { System . out . println ( " Positive " ) ; } else { System . out . println ( " Negative " ) ; } } } public static void main ( String [ ] args ) { int a = - 10 , b = - 2 ; solve ( a , b ) ; } }