Create a class named Random Program and add a static function named reverse that will accept integer e.g. 17425 and return the reverse (52471
#include <iostream>
class RandomProgram
{
public:
static int reverse(int value)
{
int result = 0;
while(value > 0)
{
result = 10 * result + value % 10;
value /= 10;
}
return result;
}
};
int main()
{
std:: cout << 17425 << " --> " << RandomProgram::reverse(17425) << "\n";
return 0;
}
Comments
Leave a comment