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
What is the use of namespace std in C++?
What is a container class?
What is a character in c++?
daily Routine of father
What is nested class in c++?
What is c++ vb?
Do the names of parameters have to agree in the prototype, definition, and call to the function?
What is virtual destructor? What is its use?
Why was c++ created?
What is a pointer how and when is it used?
How we can differentiate between a pre and post increment operators during overloading?
What are c++ files?
How does list r; differs from list r();?
Is arr and &arr are same expression for an array?
What is data types c++?