Answers for "how to check if a string is a palindrome sentence in c"

C
1

c how to check a palindrome string

#include <stdio.h>
#include <string.h>

int main(){
    char string1[20];
    int i, length;
    int flag = 0;
    
    printf("Enter a string:");
    scanf("%s", string1);
    
    length = strlen(string1);
    
    for(i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1]){
            flag = 1;
            break;
   }
}
    
    if (flag) {
        printf("%s is not a palindrome", string1);
    }    
    else {
        printf("%s is a palindrome", string1);
    }
    return 0;
}
Posted by: Guest on January-18-2022

Code answers related to "how to check if a string is a palindrome sentence in c"

Code answers related to "C"

Browse Popular Code Answers by Language