Answers

Question and Answer:

  Home  Electrical Engineering

⟩ Write a function to determine whether a string is a palindrome (same forward as reverse, such as "radar" or "mom")

/* BEGIN C SNIPET */

#include

void is_palindrome ( char *in_str ) {

char *tmp_str;

int i, length;

length = strlen ( *in_str );

for ( i = 0; i < length; i++ ) {

*tmp_str[length-i-1] = *in_str[i];

}

if ( 0 == strcmp ( *tmp_str, *in_str ) ) printf ("String is a palindrome");

else printf ("String is not a palindrome");

}

/* END C SNIPET */

 213 views

More Questions for you: