Skip to content

Commit f4b0006

Browse files
authored
Merge pull request #155 from gopikrishnanrmg/master
Added and algorithm to check if a number is palindrome
2 parents 4ede76c + 9e6cd3b commit f4b0006

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Palindromeofnumber.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int num;
9+
cout << "Enter number = ";
10+
cin >> num;
11+
12+
string s1 = to_string(num);
13+
string s2 = s1;
14+
15+
reverse(s1.begin(),s1.end());
16+
17+
if(s1 == s2)
18+
cout<<"true";
19+
else
20+
cout<<"false";
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)