This is a program to check of an input string is a palindrome which is a word reading the same forwards as it does backwards. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

This is a program to check of an input string is a palindrome which is a word reading the same forwards as it does backwards.

#include <stdbool.h> #include <stdio.h> #include <string.h> int main() { char buf[100]; bool isPalindrome = true; scanf("%s", buf); for (int i = 0, j = strlen(buf) - 1; i < j; i++, j--) { if (buf[i] != buf[j]) { isPalindrome = false; } } if (isPalindrome) { printf("%s is a palindrome.", buf); } else { printf("%s is not a palindrome.", buf); } return 0; }

15th Dec 2020, 6:02 AM
Mohan Chaudhary
Mohan Chaudhary - avatar
1 Answer
+ 1
It works correctly, what is your problem?!
15th Dec 2020, 6:17 AM
CHERIEF Houcine Abdelkader
CHERIEF Houcine Abdelkader - avatar