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 static variable and difference between(const char *p,char const *p,const char* const p).
What are constructors in oop?
How do you explain polymorphism?
How the programmer of a class should decide whether to declare member function or a friend function?
Explain differences between new() and delete()?
Can abstract class have normal methods?
Implement stack operations with pointers with appropriate exception checks.
Tell us the size of a float variable.
What is enum c++?
What is c++ w3school?
What does and I oop and sksksk mean?
Write a function to find the nth item from the end of a linked list in a single pass.
Explain the volatile and mutable keywords.
How do you invoke a base member function from a derived class in which you have not overridden that function?
Program to check whether a word is a sub-string or not of a string typed