Question

C language: Write a program that uses a function to check if a user entered string...

C language: Write a program that uses a function to check if a user entered string is a palindrome. Based on the return value of the function, the results are printed in the main() function. (do not print results in function to check for palindrome)

A palindrome reads the same forward as backward for example tacocat or civic.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Note:- if you have any query then comment below.please upvote.

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int isPalindrome(char a[])
{
int length,i;
int flag=0;
length =strlen(a);

for(i=0;i < length ;i++)
{
if(a[i] != a[length-i-1]){
flag = 1;
break;
}
}

return flag;
}

int main(){
char a[100];

printf("Enter a string: ");
scanf("%s",&a);

if (isPalindrome(a)) {
printf("%s is not a palindrome\n",a);
}
else {
printf("%s is a palindrome\n",a);
}

return 0;
}

nter a string: tacocat tacocat is a palindrome rocess returned 0 〈0x0〉 execution time : 3.708 s ress any key to continue.

nter a string: cicic cicic is a palindrome rocess returned 0 <0x0) execution time : 2.487 s Press any key to continue

Add a comment
Know the answer?
Add Answer to:
C language: Write a program that uses a function to check if a user entered string...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT