You are expected to complete this assignment individually. If you need help, you are invited to come to office hours and/or ask questions on piazza. Clarification questions about the assignments may be asked publicly. Once you have specific bugs related to your code, make the posts private.
This homework has several exercises. We are also providing you with some resources on printf and error handling for this assignment.
I have provided you the following starting files with compiling skeletons in them:
Step 1: Makefile
Because you are adding a second set of files to your directory, you need
to add a second target to your Makefile. In your makefile, add another
two lines (with a space between these and the ones already there).
hw2: hw2.h hw2.c hw2_main.c mastermind.c mastermind.h clang -Wall -o hw2 hw2.c hw2_main.c mastermind.c
Step 2: Copy files
Copy and paste each file into a file on your computer.
The code I have provided compiles - it also must
compile as shown when you turn in the code.
There are severe penalties for turning in code that does not compile.
Step 3: Copy in mastermind code from hw 1
Go to your hw1 code and copy in all of your mastermind code.
To exercise loops, you're going to do two things to complete Mastermind.
First, you are going to reimplement your mastermind code you implemented last assignment with loops. The functions num_of_color, count_exact_matches, and count_color_matches need to be implemented using loops. They are easier to read for intermediate to advanced programmers and fit better with how we break down complex problems.
Second, you are going to complete the game play. Right now, there are several things missing - it only accepts one guess, it doesn't provide proper feedback, and it doesn't determine whether the guess was correct or not. You'll need to fix it so that it allows up to 12 guesses, depending on whether the user has guessed correctly, provides proper feedback, and gives updates as to the number of guesses as they go along. There are comments in the code to help you.
Don't forget to complete this portion, test it, and commit it before moving on!There is a classic game called 20 questions, in which someone thinks of a concrete thing. The guesser has 20 questions they can ask. Each question must be in the form that it accepts a simple yes or no as the answer.
In this exercise, you are going to write the code that determines which of 10 given items that a person is thinking of, based on their answer to 5 questions. The possible items and the 5 questions have already been determined. You must keep the exact same questions, and you must ask them in exactly the order provided.
I have provided the code that gives instructions, asks the user the questions, reads in responses, and outputs the answer. However, it doesn't store the user's answers in unique variabes, and it outputs every single answer rather than the proper one.
Your job is to properly store the answers to the questions and then use those answers to print out only the one correct item. You will first be graded on correctness. You will also be graded by efficiency. Efficiency will be measured by the number of items evaluated in each conditional statement.
In this exercise, you will take an unsigned integer and print out its base 8 representation - backwards. You may not make any system calls within the procedure other than the call to printf. Do not put a \n at the end of it. You must use recursion to solve this exercise.
The number 24 is 30 in base 8, so it would print out as 03.$ svn add hw2.h hw2.c hw2_main.c mastermind.h mastermind.c
$ svn commit -m "hw2 complete"