Skip to content

Commit 717e76a

Browse files
authored
Create palindrome.cpp
1 parent b15c30c commit 717e76a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

palindrome.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<iostream>
2+
3+
using namespace std;
4+
5+
bool isPalindrome(int x) {
6+
if(x < 0)
7+
{
8+
return false;
9+
}
10+
long n = x;
11+
long Num = 0, rem;
12+
while(x != 0)
13+
{
14+
rem = x%10;
15+
Num = (Num*10)+rem;
16+
x /= 10;
17+
}
18+
19+
if(Num == n)
20+
{
21+
return true;
22+
}
23+
return false;
24+
}
25+
int main()
26+
{
27+
int x=161;
28+
int c=isPalindrome(x);
29+
if(c==0)
30+
{cout<<"false";}
31+
else{cout<<"true";}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)