Where i am going wrong PLEASE ! tell

Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn’t good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn’t start with a zero

#include
#include
using namespace std;
int check(int a)
{
int number1, sum = 0, i = 0;
while (a != 0)
{
number1 = a % 10;
if (number1 > 4)
{
number1 = 9 - number1;
}
sum += (number1*pow(10, i));
i++;
a = a / 10;
}
return sum;
}

int main()
{
long long int number, p;
cin >> number;
p = check(number);

cout << p;

return 0;

}

Hi Hitesh,
refer my code https://ide.codingblocks.com/s/639569

now i have made necessar changes what is the problem now
#include
#include
using namespace std;
int check(int a)
{
long long int number1, sum = 0, i = 0;
while (a != 0)
{
number1 = a % 10;
if (number1 > 4 && number1 != 9)
{
number1 = 9 - number1;
}
sum += (number1 * pow(10, i));
i++;
a = a / 10;
}
return sum;
}

int main()
{
long long int number, p;
cin >> number;
p = check(number);

cout << p;

return 0;

}

Hi @hhiteshbansal_40d12e2460a1738e
firstly when u send ur code save it on ide and then send link…
i have corrected ur code https://ide.codingblocks.com/s/639657
if u still face any issue try to dry run the code on 2-3 test cases… u will get better insight…

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.