Question: Programming Assignment Instructions: In this assignment you will create your code from scratch. You are to create a C file named _ _hw3.c You will
Programming Assignment
Instructions:
In this assignment you will create your code from scratch. You are to create a C file named
You will put all of your code in this file.
You may use any technique we have learned so far.
Specifications:
This assignment is split into several parts. The goal is to get you used to working with C/C++ compile-time arrays and strings.
Part 0 Create a Menu
You should create a menu that gives access to each of the parts of the assignment.
Show this menu and make it function properly. If the user inputs something incorrect, correct them and loop the menu and prompt.
Welcome to Assignment 3! Menu: 1 Single Dimension Array Processing 2 Two-D Processing Choose an option:
Part 1 Single Dimension Array
Write a void function to drive Part 1.
A Filling the array)
Create an array of characters of size 51. This is going to be a fixed size array.
Initialize the array to contain all \0 characters.
Write a function to fill the array with random lower-case letters.
Prototype example: void fillArray(char letters[], int size);
B Menu)
Give the user a menu of options to process the array:
1. Check frequency of a letter 2. Remove a letter 3. Sort
C Processing)
Menu Option 1
Get a character from the user. Either safety-check it, or force it to be lower- case.
Create a function that returns an integer. This function should take the array, the letter and the size.
Prototype: int getFrequencyOf(char letters[], int size, char item);
You will loop through the array and count each matching instance of the character the user inputted. Return the final count.
Output the result and ask if they want to do another process.
Menu Option 2
Get a character from the user. Either safety-check it, or force it to be lower- case.
Create a function that will remove ALL instances of the specified character from your array.
Prototype: void removeCharacter(char letters[], int size, char item);
This should not leave gaps in your array. Make sure you shuffle down the contents of the array to fill in the gaps. Make sure you properly place the \0
After processing the array, output the array with a printf(%s) statement to prove you processed it correctly.
Ask if they want to do another process.
Menu Option 3
Write a function to sort the array alphabetically.
Extra Credit opportunity create an O(n log n) algorithm +3 points.
Prototype: void sortArray(char letters[], int size);
NOTE Think about when this might be called. Has the user removed any letters?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
