Check if product of digits of a number at even and odd places is equal | Java implementation of the approach ; To store the respective product ; Converting integer to String ; Traversing the String ; Driver code
import java . util . * ; class GFG { static void getResult ( int n ) { int proOdd = 1 ; int proEven = 1 ; String num = String . valueOf ( n ) ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) if ( i % 2 == 0 ) proOdd = proOdd * ( num . charAt ( i ) - '0' ) ; else proEven = proEven * ( num . charAt ( i ) - '0' ) ; if ( proOdd == proEven ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int n = 4324 ; getResult ( n ) ; } }