Why my code not running

when I input, the answer is showing correctly, where is the problem coming?

Pls share your code by saving on ide…so that I could check it…

The approach you are following in your code is wrong… Try this approach as,
char ar[50];
cin>>ar;
int i=0;
if(ar[i]==‘9’)
{
i++;
}
for(;ar[i]!=’\0’;i++)
{
int digit=ar[i]-‘0’;
if(digit>=5)
{
digit=9-digit;
ar[i]=digit+‘0’;
}
}
cout<<ar;