Question: Problem 5 (18 points) write a C program, called an agrams. c, that prompts the user to enter two strings of characters S1 and S2.

 Problem 5 (18 points) write a C program, called an agrams.

Problem 5 (18 points) write a C program, called an agrams. c, that prompts the user to enter two strings of characters S1 and S2. and then determines whether these strings are anagrams of each other. The strings S1 and S2 are said to be anagrams of each other if the characters in Si can be re-arranged to produce S2 For example, the words student and stunted are anagrams, as are the words admirer and married. On the other hand, the words cats and stack are not anagrams. Clearly, a necessary condition for Si and S2 to be anagrams is that they have the same length. Note that the strings S1 and S2 do not have to consist of letters. For example, 1234567891 and 9876154321 are valid anagrams. On the other hand, the words Admirer and Married are not anagrams, since our definition of anagrams is case sensitive. Write a C program that prompts the user to enter two strings (terminated by the newline character In),determines whether these strings are anagrams of each other, and reports the results to the user Here are several sample runs of this program: /home/userXYZ/ECE15/Final> anagrams Enter the first string: 123456789! Enter the second string: 9876154321 Your strings "123456789!" and "9876!54321" are anagrams! /home/userXYZ/ECE15/Final> anagrams Enter the first string: admirer Enter the second string: married Your strings "admirer" and "married" are anagrams! /home/userXYz/ECE15/Final> anagrams Enter the first string: Admirer Enter the second string: Married Your strings "Admirer" and "Married" are NOT anagrams! /home/userXY2/ECE15/Final> anagrams Enter the first string: cats Enter the second string: stack Your strings "cats"and "stack" are NOT anagrams Hint: For each character in Si,count how many times this character appears in Si and S2, respec- tively. The strings are anagrams if and only if these counts coincide for every character of S1. Notes You can assume that the user input to your program is always valid. That is, when prompted, the user always enters a string (without whitespace) terminated by the newline character In You can also assume that the longest string the user will enter does not exceed MAXLENGTH characters, where MAXLENGTH is a symbolic constant

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!