The above program is correct. But still to increase you knowledge I have posted a simple code, just go through it.
Code:
int a=12345;
if(a<0)a=-a;
int count = 0;
int remainder, reverse=0; // ----change over here
while(a !=0 )
{
remainder = a%10; // to read the last digit -----change
a = a/10; //removes the last digit of the number; or better a /= 10
reverse = (reverse * 10) + remainder; //this statement should come before count++ else the value will be 543210
count++;
}
If you have any more problems in future do post back again. Your problem will be definitely solved.
Bookmarks