prac_008.cpp (590B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* number reverse */ 8 9 #include <iostream> 10 using namespace std; 11 12 class rev { 13 int inp, a = 0, b = 0; 14 15 public: 16 void input(); 17 void calc(); 18 }; 19 20 void rev::input() { 21 cout << "enter the number to reverse : "; 22 cin >> inp; 23 a = inp; 24 } 25 26 void rev::calc() { 27 while (inp != 0) { 28 a = inp % 10; 29 b = b * 10 + a; 30 inp = inp / 10; 31 } 32 cout << b; 33 } 34 35 int main() { 36 rev z; 37 z.input(); 38 z.calc(); 39 return 0; 40 }