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 4 difference between delete[] and delete?
What is the use of oops?
List down the guideline that should be followed while using friend function.
What is namespace & why it is used in c++?
write a function signature with various number of parameters.
Is there any difference between int [] a and int a [] in c++?
How does c++ sort work?
What do you mean by Encapsulation?
What is oops in simple words?
Can we distribute function templates and class templates in object libraries?
What is the benefit of oop?
which feature are not hold visual basic of oop?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
Why is abstraction needed?
Can static member variables be private?