Q:

write a c program to check whether the enter string palindrome or not

0

write a c program to check whether the enter string palindrome or not

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[50];
int i,len,flag=0;
printf("\n Enter the string to check for palindrome");
scanf("%s",str);
len=strlen(str);
for(i=0;i<len;i++)
{
if(str[i]!=str[len-i-1])
{
flag=1;
break;
}
}
if (flag==0)
printf("string is palindrome");
else
printf("string is not a palindrome");
getch();
return 0;
}

Output:

Enter the string to check for palindrome mom
string is palindrome
Enter the string to check for palindrome aryan
string is not a palindrome

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a c program to calculate reverse string and ... >>
<< Write a c program to input a string and find it’...