Question: C Code - Sorting Skeleton Code: // anagrams.c #include #define MAX_LENGTH 60 int areAnagrams(char [], char []); int main(void) { char phrase1[MAX_LENGTH+1], phrase2[MAX_LENGTH+1]; printf(Enter 1st

C Code - Sorting

C Code - Sorting Skeleton Code: // anagrams.c #include #define MAX_LENGTH 60

Skeleton Code:

// anagrams.c #include  #define MAX_LENGTH 60 int areAnagrams(char [], char []); int main(void) { char phrase1[MAX_LENGTH+1], phrase2[MAX_LENGTH+1]; printf("Enter 1st phrase: "); printf("%s", phrase1); // print the input printf("Enter 2nd phrase: "); printf("%s", phrase2); // print the input if (areAnagrams(phrase1, phrase2)) printf("They are anagrams. "); else printf("They are not anagrams. "); return 0; } // Return 1 if str1 and str2 are anagrams, // otherwise return 0. int areAnagrams(char str1[], char str2[]) { return 1; } 

Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S12P03/testdata/

Objective: Sorting Task statement: An anagram is a rearrangement of all the original letters in a phrase, disregarding any non letter characters. For example "A decimal point" "'m a dot in place". The website http://www.anagramsite.com/ contains a list of anagrams, some of which are rather interesting There are a few approaches to solving the problem of checking whether two phrases are anagrams of each other. One approach involves sorting. Write an algorithm of the solution that uses sorting, and implement it as anagrams.c. Test your program with the anagrams in the above website. Your program should include a function int areAnagrams (char strl[], char str2]) which returns 1 if str1 and str2 are anagrams, or 0 otherwise. You may assume that a phrase contains at most 60 characters. You may write additional functions if necessary Sample run: Enter 1st phrase: George Bush George Bush Enter 2nd phrase: He bugs Gore He bugs Gore They are 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!