Friday, October 7, 2016

Palindromic String

You have been given a String S.You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes).
Input Format
The first and only line of input contains the String S. The String shall consist of lowercase English alphabets only.
Output Format
Print the required answer on a single line.

 
SAMPLE INPUT
aba
SAMPLE OUTPUT
YES
Code:

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

int main()
{
int i,j,a;
char s[100],p[100];
gets(s);
i=0;
a=strlen(s);
for(i=1,j=a;i<a;i++,j--)
{
p[i]=s[j];
}
if(strcmp(s,p))
{
printf("YES");
}
else
{
printf("NO");
}
}