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

What are c++ tokens?

602


How can a called function determine the number of arguments that have been passed to it?

679


What is the difference between while and do while loop?

573


What is c++ and its uses?

637


Explain about Virtual Function in C++?

622






Explain how overloading takes place in c++?

585


Can member data be public?

609


What is atoi in c++?

580


What is the difference between strcpy() and strncpy()?

620


What is singleton pattern in c++?

560


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

619


How do you write a function that can reverse a linked-list?

585


What is vector string in c++?

584


What is the use of pointer in c++ with example?

572


What is namespace std; and what is consists of?

675