All '0' Replace with '5'

carnato

Vishal Yadav

Posted on January 22, 2022

All '0' Replace with '5'

Solution of the problem

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=1005;
    int ans=n;
    int p=1;
    while(n)
    {
        if(n%10==0)
        {  
         ans=ans+p*5;
        }
        n/=10;
        p=p*10;
    }
    cout<<ans;
    return 0;
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
carnato
Vishal Yadav

Posted on January 22, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related