Skip to content

Commit 0b0103b

Browse files
authored
Update palindrome.cpp
1 parent 717e76a commit 0b0103b

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

palindrome.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#include<iostream>
22

33
using namespace std;
4+
5+
void case1(int x)
6+
{ x=121;
7+
cout<<"for positive integers : "<<x<<endl;
8+
}
9+
void case2(int x)
10+
{ x=-121;
11+
cout<<"for negative integers : "<<x<<endl;
12+
}
13+
void case3(int x)
14+
{ x=10;
15+
cout<<"for integers end with zero: "<<x<<endl;
16+
}
417

518
bool isPalindrome(int x) {
619
if(x < 0)
@@ -22,12 +35,24 @@ using namespace std;
2235
}
2336
return false;
2437
}
38+
2539
int main()
2640
{
27-
int x=161;
28-
int c=isPalindrome(x);
41+
int x,c,n;
42+
case1(x);
43+
// cout<<isPalindrome(x);
44+
if(c==0)
45+
{cout<<"false"<<endl;}
46+
else{cout<<"true"<<endl;}
47+
case2(x);
48+
c=isPalindrome(x);
49+
if(c==0)
50+
{cout<<"false"<<endl;}
51+
else{cout<<"true"<<endl;}
52+
case3(x);
53+
c=isPalindrome(x);
2954
if(c==0)
30-
{cout<<"false";}
31-
else{cout<<"true";}
55+
{cout<<"false"<<endl;}
56+
else{cout<<"true"<<endl;}
3257
return 0;
3358
}

0 commit comments

Comments
 (0)