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 is Copy Constructor?

5 Answers   ABC, Siemens,


What is C++11?

1 Answers   Adobe,


What is the difference between public, private, and protected inheritance?

0 Answers   Amazon,


Tell How To Check Whether A Linked List Is Circular ?

1 Answers   IBS, Infosys,


Identify the error in the following program. include<iostream> using namespace std; void main() { int num[]={1,2,3,4,5,6}; num[1]==[1]num ? cout<<"Success" : cout<<"Error"; }

1 Answers  


what is the difference between a pointer and a reference?

0 Answers   Amazon, Blue Star, C DAC,


Write a C++ Program to find Addition of Two Numbers.

1 Answers  


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

0 Answers   Accenture,


How to convert integer to string in C++

0 Answers  


What is pass by value & reference.

0 Answers   Accenture,


What are the advantages/disadvantages of using #define?

0 Answers   Amazon,


What are string library functions(syntax).

0 Answers   Accenture,


Categories