i have done a simple program, which i asked..(don't know how many days ago.)
but i find that there is a problem..
if i give an input (for example) 1234
it shall reverse back 4321 (it does)
when i key in 100, by right it should return 001, but it returned as 1.
my question is how to make that two zeros in front visible. (is there any mistake(s) for my "this" program??)
#include <iostream>
using namespace std;
long reverse();
int main()
{ long a;
a = reverse();
cout << "The reversed number is " << a << endl;
return 0;
}
long reverse()
{
long x, y, z = 0;
cout << "Enter an integer to be reversed: ";
cin >> x;
while (x > 0){
y = x%10;
x = x/10;
z = 10 * z + y;
}
return z;
}
thank you....