Take a look at this, hope this will help.

int convertFive(int n)
{
int count = 1,num=0,rem,res;
while(n != 0) // checking whether number is not equals to zero
{
res=n/10; //breaking the last digit
rem=n%10; // finding the last digit
if(rem==0) //replacing it with 5
{
num=num+count*5; // building the new number
}
else num = num + rem*count; //if it is not 0, building the new number
count = count*10; // increasing the place value for next digit.
n=n/10;
}
return (num);
//Your code here
}

Hope this helps.