...COMP122 Week 1 Homework Part 1: Complete the following problems. (13 points) 1. What is machine code? Why is it preferable to write programs in a high level language such as C++? (2 points) Machine code is a computer programming language that a computer hardware can understand and respond to. It is much easier to understand machine language and learn how to write programs using C++. 2. What does a compiler do? What kinds of errors are reported by a compiler? (1 point) A compiler helps translate human created code into machine code for the computer. A compiler reports any errors in the code, such as syntax errors. 3. What does the linker do? (1 point) A linker takes one or two machine codes and combines them into one program. 4. What is an algorithm? (1 point) Algorithms are a list of instructions set up to complete a task. 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. (2 points) Input: diameter of the three different size pizzas and cost Output: size of pizza with the lowest cost per inch b. Identify the processing needed to convert the inputs to the outputs. (2 points) Area of each pizza in square inches= pi x (diameter divided by 2)^2 c. Design an algorithm...
Words: 805 - Pages: 4
...COMP122 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++? A machine code is consisting of a low level programming language that is executed by CPU. Writing a program in C++, a computer translate the C++ code in the machine code for the CPU to understand. 2. What does a compiler do? What kinds of errors are reported by a compiler? Compiler help translate high level programming language into machine code. That will report any syntax, type errors, and declaration errors. 3. What does the linker do? The linker takes in object of a library file which combines them into an module or load module. It can also converts object files into executable files. 4. What is an algorithm? An algorithm is a set of instructions to follow when writing any kind of programs. 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 diameter of each pizza and cost. The outputs are the prompt for the users to determine the diameter and cost of each pizza which he will finished the cost of per square inch. b. Identify the processing needed to convert the inputs to the...
Words: 1021 - Pages: 5