I'm solving the problem of reversing an integer and got the error as below :
Line 8: Char 20: runtime error: signed integer overflow: 964632435 * 10 cannot be represented in type 'int' (solution.cpp)
My code is :
public:
int reverse(int x) {
int last=x%10;
int rev=0;
while(x){
last=x%10;
rev=rev*10+last;
x=x/10;
}
return rev;
}
};
I don't know why I'm getting this error. I'm a newbie to programming. I am not able to get the concept. Please someone explain it to me and how can I proceed further.