Re: Solution in C
int reverse(int x) {
int num=x;
int unit,sum=0;
while(num!=0) {
unit = num%10;
sum=sum*10 + unit;
if (sum-((sum/10)*10) != unit) {
return 0;
} else {
num=num/10;
}
}
return sum;
}
Re: Solution in C
int reverse(int x) {
int num=x;
int unit,sum=0;
while(num!=0) {
unit = num%10;
sum=sum*10 + unit;
if (sum-((sum/10)*10) != unit) {
return 0;
} else {
num=num/10;
}
}
return sum;
}