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


Please Help Members By Posting Answers For Below Questions

What is the 4 difference between delete[] and delete?

538


What is the use of oops?

625


List down the guideline that should be followed while using friend function.

649


What is namespace & why it is used in c++?

610


write a function signature with various number of parameters.

569






Is there any difference between int [] a and int a [] in c++?

557


How does c++ sort work?

568


What do you mean by Encapsulation?

645


What is oops in simple words?

585


Can we distribute function templates and class templates in object libraries?

595


What is the benefit of oop?

573


which feature are not hold visual basic of oop?

1727


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

1839


Why is abstraction needed?

571


Can static member variables be private?

636