# CmSc150 Fundamentals of Computing I

Document Sample

```					  CmSc150 Fundamentals of Computing I
Homework 03 SOLUTIONS

1.   Next to each of the following statements write down whether it is true or false

True/False

1.   F There is only one unique general solution (algorithm) for a given problem.

2.   T All computer programs are algorithms.

3.   F All algorithms can be implemented as computer programs.

4.   F The term software refers to the physical components of a computer.

5.   T The compiler is a program that translates a high-level language program into machine code.

6.   T Two components of the central processing unit (CPU) are the arithmetic/logic unit and the
control unit.

7.   T Magnetic tape drives and floppy disk drives are examples of auxiliary (secondary) storage
devices.

2. Using the WORD editor, underline the correct answer

1.     Which of the following translates a program written in a high-level language into machine
code?
a. a mouse
b. a compiler
c. an operating system
d. an editor

2.     Which of the following most closely resembles human language?
a. a high-level language
b. a machine language
c. a RAM

3.     Of the following components of a computer, which one stores data and instructions?
a. input device
b. output device
c. arithmetic/logic unit
d. control unit
e. memory unit

4.     Of the following components of a computer, which one performs computations?
a. input device
b. output device
c. arithmetic/logic unit
d. control unit
e. memory unit

1
5.     Of the following components of a computer, which one fetches the next instruction from
RAM during program execution?
a. input device
b. auxiliary storage device
c. arithmetic/logic unit
d. control unit
e. memory unit

6.     Of the following components of a computer, which one presents the results of the processing
to the outside world?
a. input device
b. output device
c. arithmetic/logic unit
d. control unit
e. memory unit

3. Fill-In

1.     A(n) algorithm is a step-by-step procedure for solving a problem in a finite amount of time.

2.     A(n) programming language is a set of rules, symbols, and special words used to construct
a computer program.

3.     A single binary digit (that is, a single 1 or 0) is called a(n) bit.

4.     A sequence of 8 bits is known as a(n) byte.

5.     Machine language is the language made up of binary-coded instructions that are used
directly by the computer.

6.     A(n) compiler is a program that translates a high-level language program into machine code.

4. Solve problems 1.1 and 1.2 on p.55
Turn in a report (WORD document) that contains the following:
For each task from a) to h) in problem 1.2, write down:
a. your prediction – will there be an error message or not
b. what actually happens. If there is an error message, record it. If not – explain why.

(You may write the report in this document, or put it in a separate document)

2
public class Test
{
public static void main(String[] args)
{

}

}

Experiments:

a. Change Test to test                    no error, capital letter for the name
of a class is a convention, not a syntax rule
b. Change Emergency to emergency          no error, any changes in string literal are
allowed
c. Remove first quotation mark:           ‘)’ expected
The compiler looks for a closing ‘)’ before the next “, which is
considered now the beginning of a string literal

d. Remove last quotation mark          unclosed string literal
The compiler looks for a closing “

e. Change main to man                  no error, man is allowed name of a class.
However the program will not run, because it always starts with the main method

f. Change println to bogus
cannot find symbol - method bogus(java.lang.String)
the object to which the method is applied is of type String,
and all String methods are in the java.lang library.
bogus however is not there.

g. Remove the ; at the end of the println statement     ‘;’ expected
Note however that not always missing ‘;’ result in this error.
In this case the compiler finds ‘}’ and it knows that ‘}’ showld follow either
another ‘}’ or a statement, and all statements should end with ‘;’

h. Remove the last ‘}’ in the program                   ‘}’ expected
When checking the program the compiler matches all opening braces with
closing braces and find if there are incomplete pairs of {}

3

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 4 posted: 7/22/2012 language: pages: 3