Why does this code give only 60% accuracy?

#include
#include
using namespace std;

int chewbacca(int num)
{
int num1=0,num2,s=0,rem,f=1,c=0,v=0,t=0,ans=0;
num2=num;
while (num2!=0)
{
num2/=10;
s++;
}

while(num!=0)
{
	rem=num%10;
	if(rem>=5)
		rem=9-rem;
	
	if(rem==0&&f==1&&v!=s-1)
		c++;

	if(v==s-1&&rem==0)
		rem=num%10;

	if(rem!=0)
		f=0;

	num1=num1*10+rem;
	num/=10;
	v++;
}

while(num1!=0)
{
	rem=num1%10;
	if(t==1||rem!=0)
	{
		ans=ans*10+rem;
		t=1;
	}
	num1/=10;
}
return ans*pow(10,c);

}

int main() {
int num;
cin>>num;
cout<<chewbacca(num);

return 0;

}

hi @muskanrathore01_4aab76aa7dafc189
just use long long instead of int due to the large constraints

x <= 100000000000000000

just make this change… ur code will work fine and pass all test cases…

corrected code --> https://ide.codingblocks.com/s/644144

hi @muskanrathore01_4aab76aa7dafc189
is it clear now?

yes it is clear and is giving 100% accuracy, thanks

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.