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!

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

12/15/2020 6:02:40 AM

Mohan Chaudhary

1 Answer

New Answer

+1

It works correctly, what is your problem?!