Week 1 Homework
Part 1: Complete the following problems.
1. What is machine code? Why is it preferable to write programs in a high level language such as C++?
Machine code it the language that the computer understands. High level languages are better because they are easier to understand and work with.
2. What does a compiler do? What kinds of errors are reported by a compiler?
A compiler translates one computer language into another. It also pics up errors in the program being put together.
3. What does the linker do?
A linker takes multiple object files, and turns them into an executable program
4. What is an algorithm?
The list of instructions to complete a task on a program
5. Bob enters a pizza shop and notices there are three different sizes of pizzas available. Sizes are given as the diameter of the pizza in inches. The cost of a pizza is based on the size. Bob would like to know which size of pizza has the lowest cost per square inch.
a. Identify the inputs and outputs for this problem.
The inputs are the diameters and cost of each of the three different sizes, and utputs are the size of pizza with the lowest cost per inch b. Identify the processing needed to convert the inputs to the outputs.
Area of each pizza in square inches = pi * (diameter / 2)^2
Cost per square inch = cost / area
c. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.
1. Find the diameter of the first size pizza
2. Find the area of the first pizza
3. Find the cost per square inch of the first pizza
4. Find the diameter of the second size pizza
5. Find the area of the second pizza
6. Find the cost per square inch of the second pizza
7. Find the diameter of the third pizza
8. Find the cost of the third pizza
9. Find the cost per square inch of the third pizza
10. Pic the pizza with the best value
Part 2: Complete the following problems.
1. Given the