Answer to Question #47557 in C++ for Naresh

Question #47557
Write a class called reverse to reverse an unsigned integer. For
example, 8602 should be written as 2068
1
Expert's answer
2014-10-06T12:48:33-0400
#include <iostream>
#include <string>
using namespace std;
class revers
{
public:
unsigned int reverse(unsigned int num)
{
string rev = to_string(num);
std::reverse(rev.begin(), rev.end());
return unsigned int(atoll(rev.c_str()));
}
};
int main()
{
unsigned int n = 8602;
revers r;
cout << r.reverse(n);
cin.get();
cin.get();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS