Preview

Week 1 Homework

Good Essays
Open Document
Open Document
843 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Week 1 Homework
COMP122
Week 1 Homework Solutions

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 is the language which the computer hardware understands and executes. Instructions in a high-level language are closer to a natural language, such as English and therefore are easier to understand and learn than machine language.

2. What does a compiler do? What kinds of errors are reported by a compiler?

A compiler translates high level language into machine code. Compilers deal with syntax errors.

3. What does the linker do?

A linker takes one or more machine code modules generated by a compiler and combines them into a single executable program.

4. What is an algorithm?

An algorithm is a list of well-defined steps for completing 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.

Inputs: diameter and cost of each of three different size pizzas
Output: size of pizza with the lowest cost per square 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. Get diameter of first size pizza and cost of first pizza
2. Find area of first pizza = pi * (diameter of first size pizza / 2) 2
3. Find cost per square inch of first pizza = cost of first pizza / area of first pizza
4. Get diameter of second size pizza and cost of second pizza
5. Find area of second pizza = pi * (diameter of second size pizza/ 2) 2

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Nt1310 Unit 3

    • 435 Words
    • 2 Pages

    Find the volume of concrete needed to make a circular patio that has a radius of 24 feet and is 8 feet thick. Use 3.14 for pi. If necessary, round the answer to the nearest cubic foot....C…

    • 435 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Foil Lab Questions

    • 706 Words
    • 3 Pages

    3. Determine the thickness of a rectangular piece of paper with an area of 45.3 cm2 and a volume of 7.7 X 10-3 cm3. (Hints: rewrite the formula for volume as length X width X thickness. Also, what is the formula for area?)…

    • 706 Words
    • 3 Pages
    Good Essays
  • Good Essays

    1. What are some of the different substances that make up a pizza? :Cheese, tomato sauce, meat…

    • 554 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    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.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    pt1420 exam review

    • 738 Words
    • 3 Pages

    What is used to translate high level language programs to machine language (or machine code)? Compiler…

    • 738 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Julia's Food Booth

    • 1113 Words
    • 4 Pages

    A. Formulate a linear programming model for Julia that will help you to advise her if she should lease the booth.…

    • 1113 Words
    • 4 Pages
    Good Essays
  • Good Essays

    The program Pizza.java creates a class Pizza and defines methods to get and set variables in the class…

    • 436 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Assembly Language

    • 1139 Words
    • 5 Pages

    No matter how close assembly language is to machine code, the computer still cannot understand it. The assembly-language program must be translated into machine code by a separate program called an assembler. The assembler program recognizes the character strings that make up the symbolic names of the various machine operations, and substitutes the required machine code for each instruction. At the same time, it also calculates the required address in memory for each symbolic name of a memory location, and substitutes those addresses for the names. The final result is a machine-language program that can run on its own at any time; the assembler and the assembly-language program are no longer needed. To help distinguish between the "before" and "after" versions of the program, the original assembly-language program is also known as the source code, while the final machine-language program is designated the object code.…

    • 1139 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    * a set of instructions that tells a computerhow to solve a problem or carry out a task…

    • 4115 Words
    • 17 Pages
    Powerful Essays
  • Satisfactory Essays

    The total value of the surface area is 832. It is the content of the whole box which is the Borro’s cookies. If we are going to be specific, the total amount of the product is P150.00. Comparing the value of the surface area to the amount of the material, if the surface area is big the quantity of the cookies inside the box have also large amount of the product. What we paid is the cost of the container and the content of the of the Borro’s cookies. The bigger the size of the container, the bigger the content of the product.…

    • 449 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    The computer, though it may seem as an extra-intelligent marvel, is actually a dumb machine at its core! All a computer does is follow the instructions given to it beforehand. The instructions are given to the computer by a person who makes or codes the "programs" for a computer. The computer cannot understand the language that we talk. It has its own set of languages, called a Machine Language. Machine Language are in the form of Binary codes, i.e. it takes 0 and 1 as a positive or negative value, as we can see in electrical switches The programs made by a programmer are in high level language, i.e. a language that can be understood by him. The language is converted to a machine level one by a compiler, very similar to compilers- the people who translate languages between two people speaking different languages. The machine language is the lowest level of programming language, and it uses the 0s and 1s as its characters. In Binary language, the operation of a particular function depends on two electrical conditions - whether the current is on or off .These two digits used in machine level language are often called Binary Digits(or Bits in short). A compiler translates a computer program written in a human-readable computer language (like Java) into a form that a computer can execute. You have probably seen EXE files on your computer. These EXE files are the output of compilers. They contain executables - machine-readable programs translated from human-readable programs.…

    • 714 Words
    • 3 Pages
    Good Essays
  • Good Essays

    assembly language

    • 391 Words
    • 2 Pages

    A programming language that is once removed from a computer's machine language. Machine languages consist entirely of numbers and are almost impossible for humans to read and write. Assembly languages have the same structure and set of commands as machine languages, but they enable a programmer to use names instead of numbers.…

    • 391 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Compiler

    • 32912 Words
    • 132 Pages

    Machine Language Machine language is the only language directly executable on a computer, but it is very hard for humans to write: • Absolute Addresses: hard to insert code. • Numeric Codes, e.g. remember. for operations: hard to…

    • 32912 Words
    • 132 Pages
    Powerful Essays
  • Powerful Essays

    Introduction to Programming (ITE3101) Topic 1 – Basic Programming Concepts ITE3101 Introduction to Programming Basic Programming Concepts © VTC 2012 Topic 1, p.1 Introduction to Programming (ITE3101)…

    • 3042 Words
    • 30 Pages
    Powerful Essays
  • Good Essays

    In the earlier time, at the beginning of programming the “Punch Card“ was used for the programming purpose. Then with the passage of time human tried to work on the binary digits called “Machine Language”.…

    • 996 Words
    • 4 Pages
    Good Essays