write program for palindrome

Answer Posted / abhinav garg

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
int palindrome(char str[30],int len);
void main()
{ clrscr();
char str[50];
int len,a;
cout<<"Enter a string:";
gets(str);
len=strlen(str);
cout<<"\nLength of the string=>"<<len;
a=palindrome(str,len);
if(a==1)
cout<<"\n String is palindrome...";
else
cout<<"\n String is not a palindrome...";
getch();
}

int palindrome( char str[30],int len)
{ int flag=0,i;
for( i=0;i<len/2;i++)
{
if(str[i]==str[len-i])
flag=1;
}
return flag;
}

Is This Answer Correct ?    10 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use classes in c++?

573


How come you find out if a linked-list is a cycle or not?

567


What is virtual base class uses?

705


What is object in c++ example?

619


Explain linear search.

626






Can notepad ++ run c++?

538


What is the use of data hiding?

590


What are protected members in c++?

611


What is size of string in c++?

547


How long does it take to get good at leetcode?

652


What is jump statement in C++?

613


Write about c++ storage classes?

740


What is operator overloading in c++ example?

645


What are the types of array in c++?

616


What does std mean in c++?

577