prac_008.cpp
Problem Statement
prac_008.cpp
number reverse
Source Code
cpp
#include <iostream>
using namespace std;
class rev {
int inp, a = 0, b = 0;
public:
void input();
void calc();
};
void rev::input() {
cout << "enter the number to reverse : ";
cin >> inp;
a = inp;
}
void rev::calc() {
while (inp != 0) {
a = inp % 10;
b = b * 10 + a;
inp = inp / 10;
}
cout << b;
}
int main() {
rev z;
z.input();
z.calc();
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
● Author - Amit Dutta · Updated - 22 Jun 2026