Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 flush programming?

1055


What's the order in which the local objects are destructed?

1302


What is #include math h in c++?

1130


Which is better turbo c++ or dev c++?

1122


What is the precedence when there is a global variable and a local variable in the program with the same name?

1171


How do I tokenize a string in c++?

1141


What is the best c++ compiler?

1219


Is c++ double?

1092


What do the header files usually contains?

1109


How do you invoke a base member function from a derived class in which you have not overridden that function?

1181


Explain the differences between list x; & list x();.

1055


What is stack unwinding?

1202


Differentiate between structure and class in c++.

1132


Explain explicit container.

1134


Explain the difference between method overriding and method overloading in C++?

1094