Write a program to reverse a number?



Write a program to reverse a number?..

Answer / Mahavir Singh

Here's an example program in C++ to reverse a number:

```cpp
#include<iostream>
using namespace std;
void reverse(int n) {
int reversed = 0, remainder;
while (n != 0) {
remainder = n % 10;
reversed = reversed * 10 + remainder;
n /= 10;
}
cout << "Reversed number: " << reversed << endl;
}
int main() {
int num;
cout << "Enter a positive integer: ";
cin >> num;
reverse(num);
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

how we can call xml file in java file using Android platform?

2 Answers   TCS,


what are the things i had to say in personal introduction in hr round mail me to prasanna.1867@rediff.com

1 Answers  


what is posix?

1 Answers   HCL,


Programs in JAVA to get the remainder and quotient of given two numbers without using % and / operators?

2 Answers  


hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

1 Answers  


the systematic access of small computers in a distributed data processing system is referred as?

1 Answers   Mphasis,


I need source code for Enrollment System using Visual Basic 6.0/2008 database MS Access 2007 for my school thesis project...please help me..kindly send in my email jpinedamcp@gmail.com

1 Answers  


Find out the list of authorization objects which contains activity as a field? Thanks in advance.

1 Answers  


how do we provide security for web services

1 Answers  


1.what is the vesition managment.

1 Answers   IBM,


. With the help of above table EMP, perform the following operation is sql. a) Add the new column “DEPTNO” b) Rename the table c) Update table d) Modify the table if column ‘SAL’ whose data type is number (10) and you want to enter varchar2 (15) . For example $USD 20 etc.

2 Answers  


What is a PID? How is it useful when troubleshooting a system?

3 Answers  


Categories