Is Palindrome - Easy Problems - Solution to Toph.co Online Judge Problem

Is Palindrome

Limits 1s, 512 MB

Given a word, print “Yes” if it is a palindrome, otherwise “No”.
A palindrome is a word which reads the same backward as forward, e.g. racecar.

Input

The input will contain a string S (Length of S < 100).
S will contain lowercase alphabets only.

Output

Print “Yes” or “No”.


#include<stdio.h>



int main()
{
    char s[100],rev[100];
    int len=0,i,j,flag=0;
    gets(s);

    // Length of the String

    while(s[len]!='\0')
        len++;

        // Reversing it
 for(i=len-1,j=0;i>=0,j<len;i--,j++)
 {
     rev[i]=s[j];
 }

 for(i=0;i<len;i++)
 {
     if(rev[i]!=s[i])
     {
         flag=1;
         break;
     }
 }

 if(flag==0)
 printf("Yes\n");
 else
    printf("No\n");

    return 0;

}