First Mid-term - Computer Science and Engineering Department

The American University in Cairo
Computer Science & Engineering Department
CSCE 106
EXAM-I
Dr. Eman Nasr
Spring 2008
Last Name: ...........................................................
ID: ...................................
First Name: ...........................................................
*
*
*
*
*
*
*
EXAMINATION INSTRUCTIONS
Do not turn this page until asked to do so.
Exam time is 60 minutes.
Put the answers on the same question sheet; do not use any additional papers, even for
scratch.
Please make sure that you wrote your name, and ID in the indicated places.
Calculators are not allowed.
Read the honesty policy.
Sign the following statement.
HONESTY POLICY
Cheating in Exams is a violation of the honesty policy of AUC. Whispering, talking,
looking at someone else’s paper, or copying from any source is considered cheating. Any
one who does any of these actions or her/his answers indicates that s/he did any of them,
will receive a punishment ranging from zero in this exam to failing the course. If repeated, it
may lead to dismissal from AUC.
I have read the honesty policy and exam instructions and I am presenting
this exam as entirely my effort.
Signature : _______________
---------------------------------------------------------------------------------------------------------------------
DO NOT USE THIS SECTION
Group
I
II
III
IV
V
VI
VII
Total
Points
10
20
8
20
16
10
6
90
Grade
1
Group I – Multiple Choice (10 points)
Please choose only one answer for each of the following statements.
1) The largest integer number that can be stored in 8-bit two's complement format is:
a. 128
b. 127
c. 64
d. None of the above
2) The smallest integer number that can be stored in 16-bit unsigned format is:
a. 0
b. -128
c. 127
d. None of the above
3) (-15)10 in 8-bit two's complement format is:
a. 110001
b. 11110000
c. 11110001
d. None of the above
4) The representation of -0 in 16-bit two's complement format is:
a. 1000000000000000
b. 1111111111111111
c. 0000000000000001
d. None of the above
5) Summing up all even integers is a non-algorithmic problem, because:
a. It's too difficult to compute
b. It involves infinite number of operations without termination
c. No machine can do it
d. The algorithm to do it will be very long
6) Random access memory is also known as
a. primary storage.
b. main memory.
c. RAM.
d. All of the above.
7) Bit is short for
a. basic instructional technique.
b. bytes in time.
c. binary digit.
d. binary iteration.
2
8) Programs cannot be stored
a. in primary storage.
b. in secondary storage.
c. in the arithmetic and logical unit.
d. on magnetic disk.
9) A computer program is made up of
a. a flowchart and a structure chart.
b. an input device and output device.
c. step by step instructions.
d. none of the above.
10) In flow charts, the rectangular symbol represents
a. processing
b. input
c. output
d. none of the above
Group II – Listing (20 points)
Please list the following.
11) Give five predefined data types in C++
a. int________________.
b. char_______________.
c. float_______________.
d. bool_______________.
e. long_______________.
12) Give five phases of software development
a. analysis_____________.
b. design______________.
c. implementation______.
d. testing______________.
e. documentation_______.
13) Give three basic algorithmic/programming constructs
a. selection____________.
b. sequence____________.
c. repetition____________.
3
14) Give the four phases of processing a high level language program
a. compilation_________.
b. linking_____________.
c. loading_____________.
d. execution___________.
15) Give three components of the central processing unit
a. register_____________.
b. ALU_______________.
c. CU_________________.
Group III – Numbering Systems Conversion (8 points)
Please perform the following number systems conversions. Please note that
numbers are represented using the unsigned notation (8 points).
16) (1110101011)2 = ( 1653
17) (256)10 = ( 100
)8
)16
4
Group IV – Different Binary Notations (20 points)
Please convert the following numbers, given using the decimal number system, to
binary representation in a byte, using the three different representations. Please
show all of the necessary draft work. (10 points)
Q
Number
Unsigned
Sign-Magnitude
Two's Complement
18)
257
Not Possible
Not Possible
Not Possible
19)
-100
Not Possible
1110 0100
1001 1100
20)
127
0111 1111
0111 1111
0111 1111
21)
-55
Not Possible
1011 0111
1100 1001
A result of (-128)10 was produced in an accumulator of 8-bit structure. Give the
binary content of the accumulator for each of the following cases (20 points).
22) The computer is performing its operations in one's complement integer format:
0
1
1
1
1
1
1
1
23) The computer is performing its operations in two’s complement format:
1
0
0
0
0
0
0
0
24) The computer is performing its operations in sign-magnitude integer format:
NOT POSSIBLE
5
Group V – Binary mathematical operations: (16 points)
Perform the following operations using 8-bit two's-complement representation:
25) Add (-22)10 to (39)10
39
0010 0111
- 22
1110 1010
17
0001 0001
26) Subtract (24)10 from (-18)10.
- 18
1110 1110
- 24
1110 1000
- 42
1101 0110
6
Group VI – Flow chart (10 points).
27) Please design an algorithm, using a flow chart, to calculate the sum of the following series:
sum = 1 + 3 + 5 + 7 + ……. + n
up to any odd number (n) input by the user.
START
INPUT
n
iter = 1
sum = 0
OUTPUT
sum
True
iter > n ?
False
STOP
sum = sum + iter
iter = iter + 2
7
Group VII – C++ (6 points).
28) Please provide the missing six things, where indicated by a line, in the following C++ source
code.
//_ This program displays the word "Hello!" to the user
#_ include <iostream________>
using namespace std;
void main____ ()
{
cout << "Hello!" ;_
}_
8