How do we reverse a number with leading zeroes in number ? For ex: If input is 004, output should be 400.
I wrote below program but it works only when n
As ChrisF said, you need to load a string, because 4 and 004 is the same int and you cannot distinguish it after you assign it to an int variable.
int
The next thing to do is trim the string to contain just digits (if you want to be correct) and run std::reverse on it - and you're done.
std::reverse