Which loop to use

why cannot we use while loop here.why do while loop is giving correct ans.
#include
using namespace std;
int main() {
long long int i;
cin>>i;
if(i<0 || i>1000000000000)
{
return 1;
}
long long int power=1;
long long int j=0;
int rem;
while(i!=0)
{
rem=i%10;
i=i/10;
if(rem==0)
{
rem=5;
}
j=j+rempower;
power=power
10;

}
cout<<j;
return 0;

}

Use string manipulation to replace ‘0’ with ‘5’ in the integer.

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.