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 the operator in c++?

1176


Give 10 points of differences between C & C++.

1187


what are the decision making statements in C++? Explain if statement with an example?

1145


Explain Memory Allocation in C/C++ ?

1115


Why c++ does not have finally?

1147


Explain how functions are classified in C++ ?

1297


What do you mean by volatile and mutable keywords used in c++?

1043


What are the advantages of using friend classes?

1199


what is friend function in C++?

1094


What is the use of :: operator in c++?

1184


what is the drawback of classical methods in oops?

3429


What are the differences between new and malloc?

1200


Is ca high or low level language?

1132


What is the difference between c++ and turbo c++?

1297


How to invoke a C function using a C++ program?

1154