Replace Them All Question

Hi, Please tell me where i am going wrong in this code, one of test case is passed and 2 failed

Ques: Replace Them All

Code:

using namespace std;

int check(int n){
int num;
int sum = 0;
int i = 0;

while(n>0){

num = n%10;
if(num==0){
	num =5;
}
sum = (pow(10,i))*num + sum;
i++;

n = n/10;
}
return sum;

}

int main() {

int n;
cin>>n;
cout<<check(n);


return 0;

}

Don’t use pow function
it is producing wrong output

i tried for 10002
Your output : 15551 but correct output is 15552

you can also do it without pow function

Modified Code