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 the operator in c++?
Give 10 points of differences between C & C++.
what are the decision making statements in C++? Explain if statement with an example?
Explain Memory Allocation in C/C++ ?
Why c++ does not have finally?
Explain how functions are classified in C++ ?
What do you mean by volatile and mutable keywords used in c++?
What are the advantages of using friend classes?
what is friend function in C++?
What is the use of :: operator in c++?
what is the drawback of classical methods in oops?
What are the differences between new and malloc?
Is ca high or low level language?
What is the difference between c++ and turbo c++?
How to invoke a C function using a C++ program?