To gain a solid understanding of arrays and strings.
-
Given an array of n integers where n > 1, return an array of same size an input array where at every index of the output array should contain the sum of all elements in the array except the element at the given index. You can have it so that the array is input by the user.
-
Write a program that takes an array as input, removes duplicates, and outputs that array.
-
Write a program that takes a string of characters and returns the frequency of each character in that string. For characters not in the string, nothing should be printed. For instance, for input “Aabcvbc”, you should print
A = 1
a = 1
b = 2
c = 2
v = 1
You may assume the string will be all letters and that the length of the input string does not exceed 100. Try to be as efficient as possible.
- Write a program implementing the Hangman game. You may hardcode a word for the user to guess. The program should display blanks for each letter and fill those blanks as the user guesses correctly. The program should also display the bank of incorrectly guessed letters and have a limited number of allowed incorrect guesses before the player loses the game.
<b>Optional challenge: </b>create a set of words and have the game randomly choose one each time <br>
<b>Optional challenge: </b>prompt the user to play again<br>
<b>Optional challenge: </b>include ascii art corresponding to the hangman game that updates each time the user guesses incorrectly
In a text file assignment4.txt
, answer the following questions:
- Discuss the differences between strings and a character array.
- Explain the advantages and disadvantages of arrays in C.
- When does the compiler not implicitly generate the address of the first element of an array?
- How would two strings be compared to see if they’re equivalent in content?
Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment4.txt file.
All files must be submitted via GitHub by 10:00am 7/5.