basics · beginner · ~15 min

Palindrome check

Compare characters with two converging pointers.

Challenge

Implement int is_palindrome(const char *s) returning 1 if s reads the same forwards and backwards, else 0.

Starter code

#include <string.h>

int is_palindrome(const char *s) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.