+1 vote
in Mathematics by kratos

Write a function that takes one string argument and returns 1 if the given string is a palindrome otherwise returns 0. (Note: Palindrome string reads the same from both sides. For example, madam, level, malayalam are palindromes)

1 Answer

+4 votes
by kratos
 
Best answer

include<iostream.h>

include<process.h>

include<stdio.h>

include<string.h>

void palindrome(char a [ ])

{

int l=strlen(a);

char a1,b1;

for(a1=a,b1=&a[l-1];a1< = b1;a1++,b1--)

{

if(a1!=b1)

{

cout<<"No,it is not a Palindrome:";

exit(0);

}

}

cout<<"Yes,it is a Palindrome:";

}

void main()

{

char c[30];

cout<<"Enter the string:";

gets(c);

cout<<end1;

palindrome(c);

}

...