Reverse the number in C++ by R4R Team

Example-

number is 234
reverse number is 432
number is 6700
reverse number is 76

program-

#include < iostream>
int main()
{
int n,a=0;
cout<<"Enter number"< cin>>n;
while(n)
{
a=a*10+n%10;
n=n/10;
}
cout<<"Reverse is:"< return 0;
}


output-

Enter number
345609
reverse is 906543

Enter number
1200
Reverse is 21

-In this program, we take a input of the integer number and try to reverse that number and store in variable 'a' by following code
while(n)
{
a=a*10+n%10;
n=n/10;
}




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!