Write a C program to determine if the given string is a palindrome or not (Spelled same in both directions with or without a meaning like madam,civic,noon,abcba,etc.)

program:

#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;

}

output: