Question: C programming! /* Please comment on the code*/ Please write comments in the code to explain it. 16. Write a program that tests whether two

C programming! /* Please comment on the code*/

Please write comments in the code to explain it.C programming! /* Please comment on the code*/ Please write comments in

16. Write a program that tests whether two words are anagrams (permutations of the same let- ters): Enter first word: smartest Enter second word: mattress The words are anagrams Enter first word: dumbest Enter second word: stumble The words are not anagrams. Write a loop that reads the first word, character by character, using an array of 26 integers to keep track of how many times each letter has been seen. (For example, after the word smart- est has been read, the array should contain the values 1 0 001 0000000 10000 1220 0 000 0, reflecting the fact that smartest contains one a, one e, one m, one r, two s's and t's.) Use another loop to read the second word, except this time decrementing the corre- sponding array element as each letter is read. Both loops should ignore any characters that aren't letters, and both should treat upper-case letters in the same way as lower-case letters. After the second word has been read, use a third loop to check whether all the elements in e array are zero. If so, the words are anagrams. Hint: You may wish to use functions from , such as isalpha and tolower

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!