Program to determine the Quadrant of a Complex number | Function to determine the quadrant of a complex number ; Storing the index of ' + ' ; Storing the index of ' - ' ; Finding the real part of the complex number ; Finding the imaginary part of the complex number ; Driver code
function quadrant ( s ) { var l = s . length ; var i = 0 ; if ( s . indexOf ( " " ) != - 1 ) { i = s . indexOf ( " " ) ; } else { i = s . indexOf ( " " ) ; } var real = s . substr ( 0 , i ) ; var imaginary = s . substr ( i + 1 , l - 1 ) ; var x = parseInt ( real ) ; var y = parseInt ( imaginary ) ; if ( x > 0 && y > 0 ) document . write ( " " ) ; else if ( x < 0 && y > 0 ) document . write ( " " ) ; else if ( x < 0 && y < 0 ) document . write ( " " ) ; else if ( x > 0 && y < 0 ) document . write ( " " ) ; else if ( x == 0 && y > 0 ) document . write ( " " + " " ) ; else if ( x == 0 && y < 0 ) document . write ( " " + " " ) ; else if ( y == 0 && x < 0 ) document . write ( " " + " " ) ; else if ( y == 0 && x > 0 ) document . write ( " " + " " ) ; else document . write ( " " ) ; } var s = " " ; quadrant ( s ) ;