TheAlgorithms-C-Plus-Plus/Palindromeofnumber.cpp
Gopikrishnan Rajeev 227dcf0525
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.
2018-10-31 00:05:32 +05:30

21 lines
217 B
C++

#include<bits/stdc++.h>
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;
}