C Programming Code Examples C > Strings Code Examples C Program to Check if a String is a Palindrome without using the Built-in Function C Program to Check if a String is a Palindrome without using the Built-in Function - Take a string as input and store it in the array string[]. - Store the same string into the another array reverse_string[] in the reverse fashion. - Using for loop compare the elements of both the arrays. - If all the elements of the array are same, then it is a palindrome. Otherwise it is not a palindrome. #include <stdio.h> #include <string.h> void main() { char string[25], reverse_string[25] = {'\0'}; int j, length = 0, flag = 0; printf("Enter a string \n"); gets(string); /* keep going through each character of the string till its end */ for (j = 0; string[j] != '\0'; j++) { length++; } printf("The length of the string '%s' = %d\n", string, length); for (j = length - 1; j >= 0 ; j--) { reverse_string[length - j - 1] = string[j]; } /* Check if the string is a Palindrome */ for (flag = 1, j = 0; j < length ; j++) { if (reverse_string[j] != string[j]) flag = 0; } if (flag == 1) printf ("%s is a palindrome \n", string); else printf("%s is not a palindrome \n", string); }