Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions palindrome_or_not_using_class_and_object.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
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;
}