TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
siva nagarjuna
NA
26
17k
please check my code and solve the error?
Aug 23 2016 4:00 AM
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<str.Length-2;j++)
{
s[j]=str[k];
k++;
}
return ispalindrome(s);
}
else
{
return 0;
}
}
}
}
Reply
Answers (
5
)
how to apply expand/collapse in mvc4/5?
how to send image by email in c#