Integer Number Reverse

closed account (3vX4LyTq)
I'm trying to write a code that takes in a positive integer and reverses it.
For example:

Input: 123

Output: 321

but, after I input an integer, nothing happens.

Please help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;

int main() {
int num = 0;
int reversed = 0;
int remainder = 0;
cout << "I'm going to take a positive integer you enter and reverse it." << endl;
cout << "What will that number be?" << endl;
cin >> num;
while(num != 0);
{
    remainder = num%10;
    reversed = reversed*10 + remainder;
    num /=10;
}
cout << "Your reversed number is" << reversed << endl;



}
Double check line 11
That's a very nice catch.
I've been looking at the logic for a while and struggling why it doesnt work lol.
closed account (3vX4LyTq)
Damn, nice catch. Thanks, personxd1!
Topic archived. No new replies allowed.