| Is Palindrome
Limits 1s, 512 MB
Given a word, print if it is a palindrome, otherwise .
A palindrome is a word which reads the same backward as forward, e.g. racecar.
Input
The input will contain a string ().
will contain lowercase alphabets only.
Output
Print or .
Samples
Input | Output |
---|---|
racecar |
Yes |
Input | Output |
---|---|
carrot |
No |
N.B.: It's better if you solve this by your own. Thank you!
Toph Online Judge Is Palindrome Solve in C :
//Solved by Intesar#include <stdio.h>#include <string.h>
int main(){ char string1[20]; int i, length; int flag = 0; 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("No"); } else { printf("Yes"); } return 0;}
0 Comments