Replace all â €˜ 0 â €™ with â €˜ 5 â €™ in an input Integer |  ; Returns the number to be added to the input to replace all zeroes with five ; Amount to be added ; Unit decimal place ; A number divisible by 10 , then this is a zero occurrence in the input ; Move one decimal place ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int calculateAddedValue ( int number ) { int result = 0 ; int decimalPlace = 1 ; if ( number == 0 ) { result += ( 5 * decimalPlace ) ; } while ( number > 0 ) { if ( number % 10 == 0 ) { result += ( 5 * decimalPlace ) ; } number /= 10 ; decimalPlace *= 10 ; } return result ; } int replace0with5 ( int number ) { return number += calculateAddedValue ( number ) ; } int main ( ) { cout << replace0with5 ( 1020 ) ; }