From c4bd605aa98ee64e60f8ca7d01e8b926202f54aa Mon Sep 17 00:00:00 2001 From: harshp807 <57705751+harshp807@users.noreply.github.com> Date: Wed, 6 Oct 2021 15:05:31 +0530 Subject: [PATCH] Create palindrome_or_not_using_class_&_object.cpp --- palindrome_or_not_using_class_&_object.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 palindrome_or_not_using_class_&_object.cpp diff --git a/palindrome_or_not_using_class_&_object.cpp b/palindrome_or_not_using_class_&_object.cpp new file mode 100644 index 0000000..7370788 --- /dev/null +++ b/palindrome_or_not_using_class_&_object.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; + +class Test { +public: + + int reverse(int x) { + int r, rev = 0; + + while (x > 0) { + r = x % 10; + rev = rev * 10 + r; + x = x / 10; + } + return rev; + } +}; + +int main() { + + int x, rev; + + cout << "Enter a number:"; + cin >> x; + + Test obj; + rev = obj.reverse(x); + + if (rev == x) { + cout << "Number is palindrome:" << x; + } else { + cout << "Number is not palindrome:" << x; + } + + return 0; +}