Reversible numbers, or more specifically pairs of reversible numbers, are whole numbers in which the digits of one number are the reverse of the digits in another number, for example, 2847 and 7482 form a reversible pair.
C++ program to print number in reverse.
#include <iostream>
using namespace std;
int main() {
int n,r,sum=0;
cout<<"Enter Number : ";
cin>>n;
while(n!=0)
{
r=n%10;
sum=sum*10+r;
n=n/10;
}
cout<<"Reverse is : "<<sum;
return 0;
}
Output :
Another Way :
#include <iostream>
using namespace std;
int main() {
int n,r,sum=0;
cout<<"Enter Number : ";
cin>>n;
while(n!=0)
{
r=n%10;
cout<<r;
n=n/10;
}
return 0;
}
No comments:
Post a Comment