Mega Code Archive

 
Categories / C / String
 

Looking for palindromes

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