Sita's 3-year-old niece Mahirl's Birthday also falls in the coming week and she plans to get a gift for her too. Mahirl has learned to recite the English alphabets in order at the age of 2 itself.
Mahirl is currently being taught to recognize the Upper Case Alphabets in English. Sita came across a kids puzzle where there will be multiple pieces each containing 2 adjacent letters. She thought that Mahirl would enjoy this puzzle and she thought of buying it. She found that the price of this Puzzle is too low and she decided to purchase them in bulk so that it can be given as welcome gifts to all the kids attending Mahirl's Birthday party. She wants to make sure that all the pieces in each puzzle pack are valid i.e they contain only adjacent letters.
Gita says that the high tech scanner device can do this job also.
Can you guess what would be the program that is embedded in this device?
Input Format:
Input consists of a string containing 2 upper case letters.
Output Format:
The output is either 'yes' or 'no'. The output is yes if the puzzle piece is valid and is no otherwise.
Sample Input 1:
AB
Sample Output 1:
yes
Sample Input 2:
AC
Sample Output 2:
no
Sample Input 3:
BA
Sample Output 3:
yes
Program Code:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char s[10];
int q;
scanf("%s",s);
q=abs(s[0]-s[1]);
if(q==1 || q==25)
printf("yes\n");
else
printf("no\n");
return 0;
}
Post A Comment:
0 comments: