Skip to content

Commit 84a5211

Browse files
Add files via upload
1 parent c718397 commit 84a5211

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

46_checkPalindromeRecursion.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
bool checkPalindrome(string str,int start,int end){
5+
//base case
6+
if(start>end){
7+
return true;
8+
}
9+
10+
if(str[start] != str[end]){
11+
return false;
12+
}
13+
else{
14+
return checkPalindrome(str,start+1,end-1);
15+
}
16+
}
17+
int main(){
18+
// Here, we are going to check whether a given string is palindrome or not
19+
string str;
20+
cout<<"Enter the string: ";
21+
getline(cin,str);
22+
23+
bool result = checkPalindrome(str,0,str.length()-1);
24+
25+
if(result){
26+
cout<<"Palindrome"<<endl;
27+
}
28+
else{
29+
cout<<"Not Palindrome"<<endl;
30+
}
31+
32+
return 0;
33+
}

46_checkPalindromeRecursion.exe

47.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)