A string S is given as input of length n. Your task is to check whether the given string starts and ends with same character. If the given string starts and ends with same character then print "Yes", otherwise print "NO".
Constraints:
5<=n<=15
Note:
1. If the length of the string not between 5 and 15, then print "Invalid String".
2. The input contains both uppercase and lowercase alphabets.
C PROGRAM:
#include<stdio.h>
int main(void)
{
int i;
char c[30];
scanf("%s",&c);
for (i = 0; c[i] != '\0'; ++i);
if(i>=5&&i<=15)
{
if(c[0]==c[i-1])
{
printf("Yes");
}
else
{
printf("No");
}
}
else
{
printf("Invalid String");
}
}
INPUT:
teest
OUTPUT:
YES
إرسال تعليق