To Reverse any Number Using C++ Language


Program code:

#include<iostream>
using namespace std;

int main()
{
cout<<"**************************************"<<endl;
cout<<" Program to Reverse any Number "<<endl;
cout<<"**************************************"<<endl<<endl;
int num, r , rev=0;

cout<<"Enter any Number =  ";
cin>>num;
while(num)
{
r = num%10;
rev = rev * 10 + r;
num= num /10 ;
}
cout<<endl<<endl;
cout<<"Reverse of Entered number is  =    "<<rev<<endl;
cout<<"**************************************";

return 0;
}

Output:



No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.