Chewbeacca and number

test case 3 is failing ,help me to identify the error
#include
using namespace std;
int main(){
char a[50];
cin>>a;
int i;
for(i=0;a[i]!=’\0’;i++){
int digit=a[i]-‘0’;
if(digit==9);

     else  if((digit)>=5){
      digit=9-digit;  
      a[i]='0'+digit;   }}
      cout<<a<<endl;

}

Hi Pritika, you need to read the question properly. Check the constraints. You’ll have to use long or long long int. Also, the question says Help Chewbacca to transform the initial number x to the ‘minimum possible positive number’. You’re not supposed to flip the digits every time.
For example, if the input is 1111, the output should also be 1111 since we need the minimum positive number.
If the input is 01191, the output should be 1101.

this same method was discussed in the video by prateek sir ,besides all other test cases are giving correct output

Hey Pritika, your code is not working for a test case, when
input:
999999

your code’s output:
999999

but the expected output is :
900000