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
How do c++ struct differs from the c++ class?
What are c++ storage classes?
What is a manipulator in c++?
Which programming language is best to learn first?
What is stream and its types in c++?
What do you know about near, far and huge pointer?
When not to use object oriented programming?
when to use 'mutable' keyword and when to use 'const cast' in c++
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What is a storage class used in c++?
Differentiate between a constructor and a destructor in c++.
How do you invoke a base member function from a derived class in which you have not overridden that function?
What is a virtual destructor? Explain the use of it?
Write a c++ program to display pass and fail for three student using static member function
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?