Due in class on Friday, February 11.
Turn in a HARDCOPY of your source code with your NAME and STUDENT ID.
You may use any standard library functions in your code (i.e., functions documented in appendix B of K&R).
Problem: Anagrams
Anagrams are words with the property that every letter of the alphabet appears the same number of times in each word. Write a program that queries the user for pairs of words, and indicates whether or not each pair consists of anagrams. Your program should not be case-sensitive, and the word "quit" entered at any time should terminate the program.
You may assume that all words entered are of length <= 80 characters. You may also assume that all words entered as input consist only of alphabetic characters.
Hint: use scanf( "%s", ... ); to get input.
Here's an example interaction with my program; write yours so that I could have an identical interaction with it.
Enter word 1 of a pair, or 'quit' to quit: Unclear Enter word 2 of a pair, or 'quit' to quit: nuclear Unclear and nuclear are anagrams. Enter word 1 of a pair, or 'quit' to quit: Rimon Enter word 2 of a pair, or 'quit' to quit: MinOR Rimon and MinOR are anagrams. Enter word 1 of a pair, or 'quit' to quit: descartes Enter word 2 of a pair, or 'quit' to quit: aristotle descartes and aristotle are not anagrams. Enter word 1 of a pair, or 'quit' to quit: marques Enter word 2 of a pair, or 'quit' to quit: quarmse marques and quarmse are anagrams. Enter word 1 of a pair, or 'quit' to quit: mappings Enter word 2 of a pair, or 'quit' to quit: mapings mappings and mapings are not anagrams. Enter word 1 of a pair, or 'quit' to quit: Sasha Enter word 2 of a pair, or 'quit' to quit: Polonsky Sasha and Polonsky are not anagrams. Enter word 1 of a pair, or 'quit' to quit: Mutter Enter word 2 of a pair, or 'quit' to quit: RumTet Mutter and RumTet are anagrams. Enter word 1 of a pair, or 'quit' to quit: punk Enter word 2 of a pair, or 'quit' to quit: quit
Problem: Palindromes
A palindrome is a phrase such that the sequence of letters (in the phrase) is identical when read forward and backwards. For example, "Lisa Bonet ate no basil" is a palindrome. Write a program which takes any number of phrases, and evaluates each one as a palindrome or not a palindrome.
Ignore all non-alphabetic characters, and write your program so that it is not case sensitive. You may assume that all inputs are of length <= 80 characters.
Hint: To get input from the user, use the function gets, which accepts a "char *" as a parameter. (See K&R page 247).
Here's an example interaction with my program; write yours so that I could have an identical interaction with it.
Enter some phrase, or 'quit' to quit: A man, a plan, a canal: Panama... 'A man, a plan, a canal: Panama...' is a palindrome. Enter some phrase, or 'quit' to quit: I love me, Vol. I 'I love me, Vol. I' is a palindrome. Enter some phrase, or 'quit' to quit: Sore eye, Eros? 'Sore eye, Eros? ' is a palindrome. Enter some phrase, or 'quit' to quit: Joseph Mutter 'Joseph Mutter' is not a palindrome. Enter some phrase, or 'quit' to quit: A Santa spit taboo bat tips at NASA. 'A Santa spit taboo bat tips at NASA. ' is a palindrome. Enter some phrase, or 'quit' to quit: Yo-Yo 'Yo-Yo' is not a palindrome. Enter some phrase, or 'quit' to quit: Yo-Oy 'Yo-Oy' is a palindrome. Enter some phrase, or 'quit' to quit: quit