Comp181 Midterm Examination, Fall 09-10 Name Surname ...
Comp181 Midterm Examination, Fall 09-10 Name Surname ...
Comp181 Midterm Examination, Fall 09-10 Name Surname ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Comp181</strong> <strong>Midterm</strong> <strong>Examination</strong>, <strong>Fall</strong> <strong>09</strong>‐<strong>10</strong><br />
<strong>Name</strong> <strong>Surname</strong>: Number: 90 min. 18/11/<strong>09</strong><br />
Answer ALL off the following questions.<br />
1.What does the term hardware refer to?<br />
a. The relative difficulty of programming<br />
b. The physical components that a computer is made of<br />
c. The way a computer's storage space is organized<br />
d. The logical flow of instructions<br />
e. None of the above.<br />
2. At the heart of a computer is its central processing unit. The CPU's job is:<br />
a. To fetch instructions<br />
b. To carry out the operations commanded by the instructions<br />
c. To produce some outcome or resultant information<br />
d. All of the above<br />
e. None of the above<br />
3.An Integrated Development Environment typically consists of:<br />
a. A text editor<br />
b. A compiler<br />
c. A debugger<br />
d. All of the above<br />
e. None of the above<br />
4.The purpose of a memory address is:<br />
a. To identify the location of a byte in memory<br />
b. To prevent multitasking<br />
c. To obtain an algorithm<br />
d. To improve the effectiveness of high-level languages<br />
e. None of the above<br />
5.The programming process consists of several steps, which include:<br />
a. Input, Processing, and Output<br />
b. Key Words, Operators, and Punctuation<br />
c. Design, Creation, Testing, and Debugging<br />
d. Syntax, Logic, and Error Handling<br />
e. None of the above<br />
6.Programmer-defined names of memory locations that may hold data are:<br />
a. Operators<br />
b. Variables<br />
c. Syntax<br />
d. Operands<br />
e. None of the above.
7.The computer's main memory is commonly known as:<br />
a. The hard disk<br />
b. The floppy disk<br />
c. RAM<br />
d. Secondary storage<br />
e. None of the above<br />
8.The ________ decodes an instruction and generates electrical signals.<br />
a. Arithmetic and Logic Unit<br />
b. Main memory<br />
c. BIOS<br />
d. Control Unit<br />
e. None of the above<br />
9.A(n) ____________ is a set of instructions that the computer follows to solve a problem.<br />
a. Compiler<br />
b. Linker<br />
c. Program<br />
d. Operator<br />
e. None of the above<br />
<strong>10</strong>._______________ are used to translate each source code instruction into the appropriate machine<br />
language instruction.<br />
a. Modules<br />
b. Library routines<br />
c. Compilers<br />
d. Preprocessor directives<br />
e. None of the above<br />
11.A set of well-defined steps for performing a task or solving a problem is known as a(n):<br />
a. Hierarchy<br />
b. Algorithm<br />
c. Central Processing Unit<br />
d. Encoded instruction<br />
e. None of the above<br />
12.The statements written by the programmer are called:<br />
a. Syntax<br />
b. Object code<br />
c. Source code<br />
d. Runtime libraries<br />
e. None of the above<br />
13.Internally, the CPU consists of two parts:<br />
a. The Output Device and the Input Device<br />
b. The Software and the Hardware<br />
c. The Control Unit and the Arithmetic and Logic Unit<br />
d. The Single-task Device and the Multi-task Device<br />
e. None of the above<br />
14.Even when there is no power to the computer, data can be held in:<br />
a. Secondary storage<br />
b. The Input Device<br />
c. The Output Device<br />
d. The Algorithm<br />
e. None of the above
15.Words that have a special meaning and may be used only for their intended purpose are known as:<br />
a. Operators<br />
b. Programmer Defined Words<br />
c. Key Words<br />
d. Syntax<br />
e. None of the above<br />
16.The name for a memory location that may hold data is:<br />
a. Key Word<br />
b. Syntax<br />
c. Operator<br />
d. Variable<br />
e. None of the above<br />
17..This is a complete instruction that causes the computer to perform some action.<br />
a. Line<br />
b. Statement<br />
c. Variable<br />
d. Key Word<br />
e. None of the above<br />
18.An example of a secondary storage device is:<br />
a. The computer's main memory<br />
b. The keyboard<br />
c. The monitor<br />
d. A hard disk<br />
e. None of the above<br />
19.Mistakes that cause a running program to produce incorrect results are called:<br />
a. Syntax errors<br />
b. Logic errors<br />
c. Compiler errors<br />
d. Linker errors<br />
e. None of the above<br />
20.Computer programs are also known as<br />
a. hardware<br />
b. firmware<br />
c. software<br />
d. silverware<br />
e. None of the above<br />
21.This is a volatile type of memory, used for temporary storage.<br />
a. A floppy disk<br />
b. ALU<br />
c. RAM<br />
d. A hard disk<br />
e. None of the above<br />
22.This is a set of rules that must be followed when constructing a program.<br />
a. Syntax<br />
b. Punctuation<br />
c. Portability<br />
d. Operators<br />
e. Key words
23.In a C++ program, two slash marks ( // ) indicate:<br />
a. The end of a statement<br />
b. The beginning of a comment<br />
c. The end of the program<br />
d. The beginning of a block of code<br />
e. None of the above<br />
24.A statement that starts with a # is called a:<br />
a. Comment<br />
b. Function<br />
c. Preprocessor directive<br />
d. Key word<br />
e. None of the above.<br />
25.The ______ is/are used to display information on the computer's screen.<br />
a. Opening and closing braces<br />
b. Opening and closing quotation marks<br />
c. cout object<br />
d. Backslash<br />
e. None of the above<br />
26.A variable whose value can be either true or false is of this data type.<br />
a. binary<br />
b. bool<br />
c. T/F<br />
d. float<br />
e. None of the above.<br />
27. After execution of the following code, what will be the value of input_value if the<br />
value 0 is entered at the keyboard at run time?<br />
cin >> input_value;<br />
if (input_value > 5)<br />
input_value = input_value + 5;<br />
else if (input_value > 2)<br />
input_value = input_value + <strong>10</strong>;<br />
else<br />
input_value = input_value + 15;<br />
a. 15<br />
b. <strong>10</strong><br />
c. 25<br />
d. 0<br />
e. 5<br />
28.What will the following segment of code output? You can assume the user enters a grade of 90<br />
from the keyboard.<br />
cout > test_score;<br />
if (test_score < 60);<br />
cout
cout num;<br />
switch (num)<br />
{<br />
case 1:<br />
case 2: total = 5;<br />
case 3: total = <strong>10</strong>;<br />
case 4: total = total + 3;<br />
case 8: total = total + 6;<br />
default: total = total + 4;<br />
}<br />
cout
a. <strong>10</strong><br />
b. 120<br />
c. 20<br />
d. This code will not compile<br />
31.Correct the errors in the following program<br />
1 include ;<br />
2 using namespace std;<br />
3<br />
4 int Main()<br />
5 {<br />
6 const int number = 5;<br />
7 cin>>number;<br />
8 if (number >= 0 &&
35. Write down a program segment that accepts lengths of two adjacent sides, b and c, of a triangle and<br />
the angle, α , between them, in degrees then calculates the length of the third side, a, by using the<br />
formula<br />
2 2 2<br />
a = b + c − 2bccos( α)<br />
. Then obtain a trace table for b=3, c=4, α=60 0 .
36. Draw a flowchart that finds the average of given three different numbers and also the maximum,<br />
and the minimum. Please give the equivalent C++ code for your flowchart.