hw3

advertisement
Name: __________________________
Homework 3
Fall 2006
Chapter 0 in the ANSI C Book
Criteria
Accuracy
Yes
Halfway
91.101 Computing I
Due: Next Class
Care about Your Work
No
Not
Applicable
Thoroughness
Writing Skills
(spelling, grammar,
punctuation)
Creativity
Neat
On time
Please answer the following.
1) How long did it take you to do this homework?
_________ minutes
2) Did you do this homework in a well-lit area?
_________
3) Did you do this homework in a relatively distraction free location?
_________
4) Did you make a commitment to do this work with pride?
_________
5) Does this homework contain any spelling errors?
_________
6) Is this homework neat? Are you being courteous to your reader?
_________
7) Are you passing this homework in on-time?
_________
Your best friend in this course is your white textbook. Its title is Applications
Programming in ANSI C. You need to live with this book. Chew it. Squeeze it, Gnarl it
and sleep with it under your pillow. You need to know how to use it as a reference book.
You must learn how to read it. We also need to work our way through it systematically.
So you will need to use it in two ways. First you will need to bounce around it looking for
information and second, you will need to go through it page by page. You can do it.
There are a total of twelve chapters in it numbered 0 through 11. Our goal is to master the
information contained within chapters 0 through 9. We also need to know how to extract
and use the information in appendix A, appendix D, appendix E, and appendix G.
This homework concerns Chapter 0. Chapter 0 is 29 pages long. There are 6 sections in
this chapter.
Question 1: Fill in the table below.
Section What is the title of this section
How many
page long is
this section?
0.1
0.2
0.3
0.4
0.5
0.6
Total amount of
minutes it took
you to read
Chapter 0 once.
How long in
minutes did it take
you to read the
section once?
Question 2: From whose name is the word algorithm derived?
Question 3: What is an algorithm?
Question 4: What is the assignment operator?
Question 5: What is the equality operator?
Question 6: How many pages long is section 0.2?
Question 7: The components of a computer system can be divided into
________________ and ___________________ .
Question 8: At the heart of a computer’s hardware are
____________________
and ___________________________.
Question 9: The three main components of a CPU are:
a) ____________________________
b) ____________________________
c) ____________________________
Question 10: The main memory stores
________________________ and ______________________.
Question 11: Local scratchpad storage within the CPU are called _________________ .
Question 12: “Jim, I have looked at and I have thought about Figure 0.3”
Sign here if you did: ___________________________
Question 13: A storage area is considered what if its contents are lost when the power is
lost?
Question 14: What is the title of Section 0.3? _____________________________
Question 15: Including the 28 questions given on pages 17 and 18 – how long in pages
is section 0.3?
__________________
Question 16: Section 0.3 is divided into subsections. The subsections have headings that
are given in blue font. Please give me the names of the five subsections contained within
section 0.3.
a) ___________________________
b) ___________________________
c) ___________________________
d) ___________________________
e) ___________________________
Question 17: Modern digital computers can only store a 0 or a 1. A single 0 or a single 1
is called a binary digit. It is also called a ________________ .
Question 18: Eight bits make a ____________________.
Question 19: Main memory consists of a sequence of bytes. Each byte of memory has
both a content and an
_______________________ .
Question 20: The word integer is spelled I N T E G E R. This word does not contain the
letter i. Integers are represented in the computer hardware using the binary or base-2
number system. Your textbook, on pages 9 and 11, identifies two different systems used
to represent integers. They do not call them systems – perhaps technique is a better word.
They are:
a) _________________________________
b) _________________________________
In addition to these two techniques – there are three other techniques used to represent
integers. They are: Signed Magnitude, One’s Complement, and Excess notation.
Question 21: Represent the decimal integer value 62 using 8-bit unsigned binary
representation.
______ _______ _______
_______ _______ _______ _______ _______
Question 22: Hexadecimal notation is a shorthand method used to represent a string of 0s
and 1s by writing fewer symbols on the paper. You can do this by batching up 0s and 1s
in groups of 4 bits starting from the right side and moving left. Each group of four bits is
translated according to the table given in Example 0.3.4 on page 10.
“Jim, I have looked at the table and I understand how to convert from unsigned binary to
hexadecimal.”
Sign here if you do: ________________________________
Question 23: Express 0011 1111 0001 1001 0011 as a hexadecimal number.
______________________________
Question 24: What is the largest one-byte unsigned binary number. Express your answer
using the decimal notation we grew up with.
_______________________
Question 25: On pages 11, 12, and 13 you will find examples 0.3.5, 0.3.6, 0.3.7, and
0.3.8. Please study these four examples – do not just jump over them and think that you
do not have to read them closely. After doing so, sign one of the two spaces below.
“Jim, I have read the examples and I understand them.”
Signed: ___________________
or
“Jim, I have read the examples and I do not understand them.”
Signed_________________
You will be required to know how to represent, add, and subtract twos complement
numbers.
Failing to prepare is preparing to fail.
John Wooden
YOU CAN BE A GREAT STUDENT. GIVE YOURSELF A CHANCE.
Jim Canning
Give me a lever long enough and the moon as my fulcrum and I can move the
Earth.
Achimedes
Question 26: On pages 13, 14, and 15 you will find examples 0.3.9, 0.3.10, and 0.3.11.
They all concern floating point numbers. I will explain floating point numbers to you in
class some day soon. However, I do want you prepared to listen. You should work your
way through these three examples. For now, I want you to know that a floating point
number is expressed using scientific notation. Scientific notation has three components:
Mantissa
Base
Exponent
Today, computers generally used the IEEE 754 format to represent floating point
numbers. The single precision format is 32 bits long. The double precision format is 64
bits long.
I will expect you to know how to take a decimal floating point number, say 53.1219, and
then represent it in IEEE 754 format.
“Jim, I am ready, eager, able, and willing to learn how to do this. I will give it my all and
I will not whine about it.”
Signed: _____________________________
Question 27: What does the acronym ASCII stand for?
______________________________________________________________________
Question 28: “Jim I know that a computer program written in a high level language like
C needs to be converted into its machine instruction equivalent.”
Signed: ______________________________
Question 29: Section 0.4 is entitled Programming Languages. It introduces the notion
that an algorithm can be represented in a high level language, say C, or it could be
represented in assembly language, or it can be represented in machine language (1s and
0s). A compiler converts a program written in a high level language into is assembly
language equivalent. An assembler converts a program written in assembly language into
its machine language equivalent. A linker is responsible for building an executable
image. A loader is responsible for moving an executable image and putting it into main
memory. A process image is the part of main memory dedicated to an executable image.
For us, a process image will contain four areas. They are: Code, Global and Static Data
Area, Heap, and the Run-Time Stack.
Got it?
Sign here if you do: ___________________________________
Question 30: Perhaps the most difficult skill to acquire is loosely discussed in section
0.5. In brief, the skill you need to acquire is how to read a problem specification and then
convert it into an algorithm. For some of you this will come easy. For others – this will
not come so easy. I cannot help you a whole lot. Experience matters. You just need to
begin solving lots of problems and adding solutions to your history. You can learn by
reading solutions too. For most problems you need to find the correct insight. This is
same situation you were in when your middle and high school math teachers asked you to
solve word problems. You must read and reflect. I do believe all of you can do it – but
some of you will require time and practice. The good news is – once acquired – you own
it. Like bicycle riding.
Will you be up for the programming challenges that lie ahead ?
“Yes Jim, bring them on. Let’s play ball.”
Sign here: __________________________
Question 31: Section 0.6 is entitled, Why C?
List the eight reasons why the authors give for learning C.
Congratulations. If you’ve taken this homework seriously you have now read Chapter 0
for the first time. We have not yet practiced too many problems, but you have started a
wonderful journey. Stay committed to learning all that you can. I am here to help you –
but you need to do it yourself. You can do it. I am mostly here to show you the way.
Let’s be strong. You can be strong. You need to start removing whatever accumulated
error is stuck on your back. When distractions come your way – leave them behind and
come to Olsen Hall with your textbooks. It would be worth it.
Remember the correct spellings are …
RECEIVE
Question 32:
SEPARATE
Download