Compiled but not submit

#include
using namespace std;
void cb(int n){
int r,num=0,p=1,f;
while(n>0){
r=n%10;
n=n/10;
f=9-r;
if(f<r){
num=num+fp;
}
else{
num=num+r
p;
}
p*=10;
}
cout<<num;
}

int main() {
int n;cin>>n;
cb(n);
return 0;
}

this code is compiled successfully but not submitting

hi @yashtripathi6969_0cd127807d833066 try 999 ans is 900 (as first digit cant be 0) so check if first digit is 0 then dont change it and use long long