Write in C language Description Write a program to determine if a string is apalindrome or not. Input Input string will include only letter,please consider uppercase and lowercase as the same. Output Please refer to the sample output. Sample Input 1 AbcBa Sample Output 1 AbcBa is a palindrome. Sample Input 2 AAaab Sample Output 2 AAaab is not a palindrome.
Write in C language
Description
Write a program to determine if a string is apalindrome or not.
Input
Input string will include only letter,please consider uppercase and lowercase as the same.
Output
Please refer to the sample output.
Sample Input 1
AbcBaSample Output 1
AbcBa is a palindrome.Sample Input 2
AAaabSample Output 2
AAaab is not a palindrome.Expert Answer (Output doesn't match Sample output)
#include <stdio.h>
#include <string.h>
int main(){
char string1[20];
int i, length;
int flag = 0;
printf("Enter a string:");
scanf("%s", string1);
length = strlen(string1);
for(i=0;i < length ;i++){
if(string1[i] != string1[length-i-1]){
flag = 1;
break;
}
}
if (flag) {
printf("%s is not a palindrome", string1);
}
else {
printf("%s is a palindrome", string1);
}
return 0;
}
OUTPUT
Enter a string : Wow
Wow is a palindrome (saying not a palindrome)
Press any key to continue

Step by step
Solved in 2 steps









