Not able to solve this problem

kindly see the following code. it is giving error in test case 2 and 3

#include
#include<math.h>
using namespace std;
int replace(int n){
int i,j,k=0;
i=n;
int sum=0;
while(i>0){
j=i%10;
if(j==0){
j=5;
}
i=i/10;
sum=sum+(j*pow(10,k));
k++;

}
return sum;

}
int main(){
int n;
cin>>n;
cout<<replace(n);
}

hey, due to the constraints 0<=n<=1000000000000 make int as long long int everywhere… secondly for input as 0, expected o/p is 5, but ur code gives o/p 0. so add a base case that if n==0, simply return 5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.