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

    A circle has an area of 153.86 square inches. Using 3.14 for pi, find the radius and circumference of the circle. Round your answer to the nearest hundredth when necessary.....A…

    • 435 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    2. Compare cost per square inch of pizza for each pan size offered by a restaurant.…

    • 1753 Words
    • 8 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

    Copyright © 2012 Pearson Education, Inc. 0-5 Terminology • Machine instruction: An instruction (or command) encoded as a bit pattern d) d d tt recognizable by the CPU • Machine language: The set of all instructions recognized by a machine Copyright © 2012 Pearson Education, Inc. 0-6 3 Machine Language Philosophies • Reduced Instruction Set Computing (RISC) – Few, simple, efficient, and fast instructions – Examples: PowerPC from Apple/IBM/Motorola and ARM • Complex Instruction Set Computing (CISC) –…

    • 783 Words
    • 4 Pages
    Satisfactory 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

    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
  • 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

    There are a lot of programming languages at present. There are many computer languages - "FORTRAN", "COBOL", "BASIC", "Pascal", "C++", "Java", etc. - just like there are many human languages. They all express approximately the same concepts in different ways. They all have their own features, for example BASIC language is a very easy language to start with, but is not so much versatile compared to C++. Using C++, it is even possible to control the hardware of your system,…

    • 714 Words
    • 3 Pages
    Good Essays
  • Better Essays

    Because the first generation languages were regarded as very user unfriendly people set out to look for something faster and easier to understand. The result was the birth of the second generation languages (2GL) at the mid of the 1950's. These generation made use of symbols and are called assemblers. An assembler is a program that translates symbolic instructions to processor instructions.…

    • 948 Words
    • 3 Pages
    Better 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
  • Good Essays

    assembly language

    • 391 Words
    • 2 Pages

    Intermediate-level programming language which is higher (is easier to use buy runs slower) than machine language and lower (is more difficult to use but runs faster) than a high-level language such as Basic, FORTRAN, or Java. Programs written in assembly language are converted into machine language by specialized programs called assemblers or compilers for their execution by the machine (computer).…

    • 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
  • 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
  • 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