here i write a program to check the given string is plindrome or not by using recursion function.iam getting exception here please solve it.
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prime
{
class Program
{
public static void Main()
{
Program p = new Program();
Console.WriteLine("enter a string");
string s1 = Console.ReadLine();
//string s1 ="madam";
char[] str = s1.ToCharArray();
Console.WriteLine( p.ispalindrome(str));
Console.ReadLine();
}
int ispalindrome(char[] str)
{
char[] s = new char[str.Length - 2];
if(str.Length==0||str.Length==1)
return 1;
if(str[0]==str[str.Length-1])
{
int k = 1;
for(int j=0;j
s[j]=str[k];
k++;
}
return ispalindrome(s);
}
else
{
return 0;
}
}
}
}
Rajeesh MenothPosted Aug 23, 2016, 10:38 AM
Bikesh SrivastavaPosted Aug 23, 2016, 9:44 AM
Nitin SontakkePosted Aug 23, 2016, 5:28 AM
{Ajay MalikPosted Aug 23, 2016, 5:08 AM
Joginder BangerPosted Aug 23, 2016, 4:14 AM