You are on page 1of 1

Q1:

#include<iostream>
#include<string>
using namespace std;
int checkPalindrome(char* p, int start, int end)
{
if (start>=end)
{
return 1;
}
else if (p[start] == p[end])
{
checkPalindrome(p, start + 1, end - 1);
}
else
{
return 0;
}
}
void main()
{
char s[20];
cout << "Enter the string to check=";
cin >> s;
int l;
l = strlen(s);
if (checkPalindrome(s, 0, l - 1))
{
cout << "String is a Palindrome" << endl;
}
else
{
cout << "String is not a Palindrome" << endl;
}
system("pause");

Output:

You might also like