From 6f654dd9d51206bab42d958c0291b4fb4a38d5a2 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Tue, 5 Oct 2021 18:19:20 +0530 Subject: [PATCH] Adding code for Palindrome_Number. --- .vscode/settings.json | 5 +++ .../Palindrome_Number/Palindromenumber.cpp | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 Programming/C++/Palindrome_Number/Palindromenumber.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0cba2e6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "iostream": "cpp" + } +} \ No newline at end of file diff --git a/Programming/C++/Palindrome_Number/Palindromenumber.cpp b/Programming/C++/Palindrome_Number/Palindromenumber.cpp new file mode 100644 index 0000000..d13d3e4 --- /dev/null +++ b/Programming/C++/Palindrome_Number/Palindromenumber.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + +int main() +{ + +int x, rev = 0, rem, ori; + cout<<"Enter an integer: "; + cin>>x; + + ori=x; + while (x != 0) + { + rem = x % 10; + rev = rev * 10 + rem; + x /= 10; + } + +if (ori>0) +{ + + if(ori==rev) + cout<<"True"; + else + cout<<"False"; +} +else +{ + cout<<"False"; + +} + return 0; + + +} \ No newline at end of file