Check if product of digits of a number at even and odd places is equal | C ++ implementation of the approach ; To store the respective product ; Converting integer to string ; Traversing the string ; Driver code
#include <iostream> NEW_LINE using namespace std ; void getResult ( int n ) { int proOdd = 1 ; int proEven = 1 ; string num = to_string ( n ) ; for ( int i = 0 ; i < num . size ( ) ; i ++ ) if ( i % 2 == 0 ) proOdd = proOdd * ( num [ i ] - '0' ) ; else proEven = proEven * ( num [ i ] - '0' ) ; if ( proOdd == proEven ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int n = 4324 ; getResult ( n ) ; return 0 ; }