Check whether a + b = c or not after removing all zeroes from a , b and c | Function to remove zeroes ; Initialize result to zero holds the Result after removing zeroes from no ; Initialize variable d to 1 that holds digits of no ; Loop while n is greater then zero ; Check if n mod 10 is not equal to zero ; store the result by removing zeroes and increment d by 10 ; Go to the next digit ; Return the result ; Function to check if sum is true after Removing all zeroes . ; Call removeZero ( ) for both sides and check whether they are equal After removing zeroes . ; Driver code
< ? php function removeZero ( $ n ) { $ res = 0 ; $ d = 1 ; while ( $ n > 0 ) { if ( $ n % 10 != 0 ) { $ res += ( $ n % 10 ) * $ d ; $ d *= 10 ; } $ n = floor ( $ n / 10 ) ; } return $ res ; } function isEqual ( $ a , $ b ) { if ( removeZero ( $ a ) + removeZero ( $ b ) == removeZero ( $ a + $ b ) ) return true ; return false ; } $ a = 105 ; $ b = 106 ; if ( isEqual ( $ a , $ b ) ) echo " Yes " ; else echo " No " ; ? >