Reverse a number, Using class reverse a number, Class program example
The simple example of CLASS in C++, To find the reverse of a number using the class:

Program Code:
#include <iostream>
using namespace std;
class reverse
{
int a,rev,rem;
public:
void result();
};
void reverse :: result ()
{
rev=0;
cout<<"Enter any number: ";
cin>>a;
while(a!=0)
{
rem=a%10;
rev=rev*10+rem;
a=a/10;
}
cout<<endl<<"Reverse of the number is = "<<rev;
}
int main() 
{
reverse r;
r.result();
}

The output of the program is tested on www.jdoodle.com

Output:
Enter any number: 13211
Reverse of the number is = 11231


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: