From 227dcf0525e2a60f1c2209a9de8e492f868c186b Mon Sep 17 00:00:00 2001 From: Gopikrishnan Rajeev Date: Wed, 31 Oct 2018 00:05:32 +0530 Subject: [PATCH] Added and algorithm to check if a number is palindrome Added the algorithm to convert number to string and check if it's a palindrome. --- Palindromeofnumber.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Palindromeofnumber.cpp diff --git a/Palindromeofnumber.cpp b/Palindromeofnumber.cpp new file mode 100644 index 000000000..a960ec854 --- /dev/null +++ b/Palindromeofnumber.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ +int num; +cin>>num; + +string s1 = to_string(num); +string s2 = s1; + +reverse(s1.begin(),s1.end()); + +if(s1==s2) + cout<<"true"; +else + cout<<"false"; + +return 0; +}