Mega Code Archive

 
Categories / C / Code Snippets
 

Looking for palindromes

#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char sentence_chars[500] ="level"; int x = 0; int j = 0; int length = 0; length = strlen(sentence_chars); for(x = 0 ; x<length/2 ; x++){ if(sentence_chars[x] != sentence_chars[length-1-x]) { printf("\n The sentence you entered is not a palindrome.\n"); break; } } }