Question: Hi, could you help me write a c++ code? Just to let you know that this is a beginner level so the codes shouldn't be

Hi, could you help me write a c++ code? Just to let you know that this is a beginner level so the codes shouldn't be to high level

Anagrams Definition:

Anagrams are words or phrases you spell by rearranging the letters of another word or phrase. For instance, fans of the Harry Potter series know that Lord Voldemorts full name is actually an anagram of his birth name, and some people even play games challenging one another to make anagrams still relevant to the original term. For example, "schoolmaster" can be turned into "the classroom", "punishments" becomes "nine thumps", and "debit card" turns into "bad credit".

The only rule is that all the letters from the original word or phrase must be used when theyre reordered to say something entirely different.

For this assignment, we will consider words with no spaces.

Program Description:

  1. Write a program called a07.cpp that tests whether two words are anagrams (permutations of the same letters).

  2. Use strings or char arrays to read the 2 words.

  3. 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.

  4. 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[]);

  1. Now, pass the second word and the second int array to the same function in step 4.

  2. Now, you will have 2 int arrays that are populated with letter counts.

  3. 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]);

  1. You must use the above 2 functions

Hi, could you help me write a c++ code? Just to let

Sample runs Below are two sample runs. Test your program with the following data (input is in blue): 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

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!