CSCI 103 - Spring 2024 Introduction to Programming

CS102 Spring 2021 Final - Anagram

An anagram is a rearrangement of a given set of letters to form a different word. For example, StoP and Tops are anagrams (ignoring case). The program below should take in two strings and determine if they are anagrams (ignoring upper or lower case). You are given the code below which provides a set of functions and a skeleton for main(). Fill in the blanks in main() to arrive at a correct program by ONLY calling the appropriate functions, performing assignment, and possibly using simple arithmetic operations. You may NOT alter any other code in main().

You may not need ALL the functions defined in the code; use only the ones you need and you may call a function more than once. You should read/analyze the code in the various functions to determine what they do and then consider how they can be used to determine if the two input strings are anagrams (ignoring case). The generally strategy is to iterate through the letters of one word, attempting to find and “cross off” the corresponding letter in the other. If only “crossed off” letters remain at the end, we know the two inputs were anagrams.

To help you understand the functions, we will ask some tracing questions about the functions that you need to answer for partial credit. By answering those questions, you will better understand how all the functions work and can decide how to use them to achieve the overall task. The questions are at the top of the skeleton code. Enter your answers in the comments of the linked .cpp skeleton file or directly on the PDF page below.


The skeleton file can be downloaded with the link: anagram.cpp

(You may need to right-click and choose Save As or Save Target As to download the .cpp file or open it in your browser and save the file.).