Answer to Question #269921 in C for DEADPOOL

Question #269921

A palindrome is a word, phrase, number or other sequence of characters which reads the same backward and forward. Write a C program that enter a word, store it in an array and determine whether it is palindrome or not.


Example : CIVIC is a palindrome

HOT is a not a palindrome


1
Expert's answer
2021-11-22T15:17:42-0500
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
    char str[256];
    int n, i;
    int isPalindrome=1;

    scanf("%s", str);
    n = strlen(str);

    for (i=0; i<n/2; i++) {
        if (tolower(str[i]) != tolower(str[n-1-i])) {
            isPalindrome = 0;
            break;
        }
    }
    printf("Word \"%s\" %s a palindrome\n", str,
            isPalindrome ? "is" : "is not");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS