From 717e76a2ae643d388cc034057fb582a3cc0cb2cb Mon Sep 17 00:00:00 2001 From: Monika Basene <113535275+Monika3002@users.noreply.github.com> Date: Fri, 7 Oct 2022 17:31:34 +0530 Subject: [PATCH 1/2] Create palindrome.cpp --- palindrome.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 palindrome.cpp diff --git a/palindrome.cpp b/palindrome.cpp new file mode 100644 index 0000000..7d63d00 --- /dev/null +++ b/palindrome.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + + bool isPalindrome(int x) { + if(x < 0) + { + return false; + } + long n = x; + long Num = 0, rem; + while(x != 0) + { + rem = x%10; + Num = (Num*10)+rem; + x /= 10; + } + + if(Num == n) + { + return true; + } + return false; +} + int main() + { + int x=161; + int c=isPalindrome(x); + if(c==0) + {cout<<"false";} + else{cout<<"true";} + return 0; + } From 0b0103b6f51a87b9dc70e8ff427f5b9b361e3f1b Mon Sep 17 00:00:00 2001 From: Monika Basene <113535275+Monika3002@users.noreply.github.com> Date: Fri, 7 Oct 2022 19:19:08 +0530 Subject: [PATCH 2/2] Update palindrome.cpp --- palindrome.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/palindrome.cpp b/palindrome.cpp index 7d63d00..996524a 100644 --- a/palindrome.cpp +++ b/palindrome.cpp @@ -1,6 +1,19 @@ #include using namespace std; + + void case1(int x) + { x=121; + cout<<"for positive integers : "<