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.



Write a C++ Program to Reverse a Number using while loop...

Answer / 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

More C++ Interview Questions

What are issues if we mix new and free in C++?

0 Answers  


What is a memory leak in C++?

0 Answers   Agilent,


Write a program to read the values a, b and c and display x, where x=a/b–c. Test the program for the following values: (a) a = 250, b = 85, c = 25 (b) a = 300, b = 70, c = 70

1 Answers  


What are the costs and benefits of using exceptions?

0 Answers   Amazon,


What is function overloading and operator overloading in C++?

0 Answers   IBS, TCS,


What does it mean to take the address of a reference?

0 Answers   Amazon,


What is data abstraction? How is it implemented in C++?

0 Answers   Amdocs,


What is partial specialization or template specialization?

0 Answers   Amazon,


What is static variable and difference between(const char *p,char const *p,const char* const p).

0 Answers   Accenture,


Can we call a virtual function from a constructor?

1 Answers  


What is C++11?

1 Answers   Adobe,


What is a virtual function in C++?

0 Answers   C DAC,


Categories