Quizzes
Write a function (with a name of your choice) which take a string and returns an int. If the string looks the same when read forward and backward, return 1, else return 0.
#include <string.h>
int palindrome(char *s)
{
char *e;
e = s + strlen(s) -1;
while( s < e ) {
if (*s != *e)
return 0;
++s;
--e;
}
return 1;
}
Previous slide
Next slide
Back to first slide
View graphic version