Write a C++ Program to Reverse a Number using while loop.
Answer Posted / hr
Solution:
/* C++ Program to Reverse a Number using while loop */
#include<iostream>
using namespace std;
int main()
{
int no,rev=0,r,n;
cout<<"Enter any positive number :: ";
cin>>n;
no=n;
while(no>0)
{
r=no%10;
rev=rev*10+r;
no=no/10;
}
cout<<"
Reverse of a Number [ "<<n<<" ] is :: [ "<<rev<<" ]
";
return 0;
}
Output:
/* C++ Program to Reverse a Number using while loop */
Enter any positive number :: 123456
Reverse of a Number [ 123456 ] is :: [ 654321 ]
Process returned 0
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is stack unwinding?
Explain virtual inheritance?
What is a dynamic binding in c++?
CDPATH shell variable is in(c-shell)
Why do we need constructors in c++?
What's the best free c++ profiler for windows?
How long does it take to get good at leetcode?
How long will it take to learn programming?
Explain the concepts involved in Object Oriented programming.
Is swift faster than c++?
How do I use arrays in c++?
What is double in c++?
Can you inherit a private class?
Write about a nested class and mention its use?
Difference between pass by value and pass by reference?