Answer to Question #182320 in C for jhon

Question #182320

Write a program using string function that determines if the input word is a  palindrome. A palindrome is a word that produces the same word when it is  reversed. 


1
Expert's answer
2021-04-18T23:16:28-0400
#include <stdio.h>
#include <string.h>


void isPalindrome(char str[])
{
    int i = 0;
    int l = strlen(str) - 1;


    while (l > i)
    {
        if (str[i++] != str[l--])
        {
            printf("%s is Not Palindrome", str);
            return;
        }
    }
    printf("%s is palindrome", str);
}


int main()
{
    char s[50];
    printf("Enter a string ");
    scanf("%s",s);
    isPalindrome(s);
    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