Question: C++ PLEASE Write a program called a07.cpp that tests whether two words are anagrams (permutations of the same letters). Use strings or char arrays to
C++ PLEASE
-
Write a program called a07.cpp that tests whether two words are anagrams (permutations of the same letters).
-
Use strings or char arrays to read the 2 words.
-
Use an int array of 26 characters (for the 26 letters from a to z) to keep count of the occurrence of each letter. Use 2 such int arrays, one for each word.
-
Pass the string, and the array to a function that will count the occurence of the letters. Here is a prototype:
void occurrence(string word, int count[]);
-
Now, pass the second word and the second int array to the same function in step 4.
-
Now, you will have 2 int arrays that are populated with letter counts.
-
Then pass the 2 count arrays to equal_array function that will return true if the words are anagrams and false otherwise. Here is a prototype:
bool equal_array(int count1[26], int count2[26]);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
