Why does this code of Challenges-Function give only 33.33% accuracy, output is correct

#include
#include
using namespace std;

int replace(int n)
{
int rem,num1,i=0;
num1=0;

while(n!=0)
{
	rem=n%10;
	if(rem==0)
	rem=5;
	num1=rem*pow(10,i)+num1;
	i++;
	n/=10;
}
return num1;

}

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

hi @muskanrathore01_4aab76aa7dafc189
just use long long int instead of int as constraints are large

0<=n<=1000000000000

just make this change and ur code will work fine and pass all test cases…
corrected code --> https://ide.codingblocks.com/s/644143

This code gives 66.67% accuracy but still not 100%

yes yes… the above code was not handling the case when n is 0, the ans should be 5 but code returned 0…
just add a base case if n=0, simply return 5
corrected code --> https://ide.codingblocks.com/s/644145

hi @muskanrathore01_4aab76aa7dafc189
is it clear now???

yes it is clear now and giving 100% accuracy

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.