C program to check whether the word is palindrome or not

#include <stdio.h> #include <string.h> int main() { char string1[20]; int i, length; int flag = 0; printf("Enter a string:"); /*scanf("%s", string1);*/ gets(string1); length = strlen(string1); for(i=0;i < length ;i++){ if(string1[i] != string1[length-i-1]){ flag = 1; break; } } if (flag==1) { printf("%s is not a palindrome", string1); } else { printf("%s is a palindrome", string1); } return 0; }

OUTPUT

C program to check whether the word is palindrome or not

Comments

Popular posts from this blog

C Program for SCAN Disk Scheduling Algorithm | C Programming

C program to Find Cartesian Product of Two Sets | C programming

C Program To Check The String Is Valid Identifier Or Not | C Programming