What is my mistake in this code

#include
#include
using namespace std;
int main()
{
long long int n, number, i = 0, sum = 0;
cin >> n;
while (n != 0)
{
number = n % 10;
if (number == 0)
{
number = 5;
}
sum = sum + number * pow(10, i);
n /= 10;
i++;
}

cout << sum;
return 0;

}

Hi Hitesh,
so ur code is failing on one test case ie. if n = 0, here o/p should be 5 but ur code prints 0… so just put a checking condition that if n = 0, it will print 5 and return…
i have corrected ur code… it will pass all test cases now https://ide.codingblocks.com/s/639643

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.