60 608
Assignments Done
97,8%
Successfully Done
In April 2018

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
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions