Exam1

Page 1

HIGHER INSTITUTE OF TECHNOLOGY-10th of RAMADAN

EXAM DURATION: 60 MINUTES

COMPUTER SCIENCE DEPARTMENT

Apr. 2015

STRUCTURED PROGRAMMING *Student Name:

Exam #1 * Student ID:

Mark:

30

_________________________________________________________________________________________ Q1: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Words that have a special meaning and may be used only for their intended purpose are known as: A) operators B) key words C) programmer defined words D) syntax E) None of these Answer: B 2) A(n) ________ is a set of instructions that the computer follows to solve a problem. A) program B) compiler C) linker D) operator E) None of these Answer: A 3) The statements written by the programmer are called: A) syntax B) runtime libraries C) source code D) object code E) None of these Answer: C 4) A set of well-defined steps for performing a task or solving a problem is known as a(n): A) hierarchy B) encoded instruction C) central processing unit D) algorithm E) None of these Answer: D 5) Which of the following is a preprocessor directive? A) pay = hours * rate; B) cin >> rate; C) // This program calculates the user's pay. D) #include <iostream> E) int main( ) Answer: D

1


6) In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies; what is the value of cookies after the execution of the statement? A) 0 B) 9 C) .5 D) 2 E) None of these Answer: D 7) This is used to mark the end of a complete C++ programming statement. A) pound sign B) data type C) semicolon D) void E) None of these Answer: C 8) What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl;

A) 72 B) 15 C) 63 D) 12 E) None of these Answer: D 9) Which data type typically requires only one byte of storage? A) double B) int C) float

D) short

E) char

D) ||

E) %

Answer: E 10) What is the modulus operator? A) * B) &

C) +

Answer: E 11) Which escape sequence causes the cursor to move to the beginning of the current line? A) \n B) \r C) \a D) \t Answer: B

2

E) \b


12) Of the following, which is a valid C++ identifier? A) ___department B) June1997 C) _employee_number D) myExtraLongVariableName E) All of the above are valid identifiers. Answer: E 13) The ________ is/are used to display information on the computer's screen. A) cout object B) opening and closing braces C) backslash D) opening and closing quotation marks E) None of these Answer: A 14) ________ are used to translate each source code instruction into the appropriate machine language instruction. A) Modules B) Compilers C) Library routines D) Preprocessor directives E) None of these Answer: B 15) A variable whose value can be either true or false is of this data type. A) binary B) bool C) float D) T/F E) None of these Answer: B

3


16) Look at the following program and answer the question that follows it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

// This program displays my gross wages. // I worked 40 hours and I make $20.00 per hour. # include <iostream> using namespace std; int main( ) { int hours; double payRate, grossPay;

}

hours = 40; payRate = 20.0; grossPay = hours * payRate; cout << "My gross pay is $" << grossPay << endl; return 0;

Which line(s) in this program cause output to be displayed on the screen? A) 8 and 9 B) 15 C) 13 D) 13 and 14

E) 14

Answer: E 17) What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday"; A) MondayTuesdayWednesday

B) Monday Tuesday Wednesday

C) Monday Tuesday Wednesday

D) "Monday" "Tuesday" "Wednesday"

Answer: A 18) What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; A) xyz

B) 012

C) 0 1 2

Answer: B

4

D) 0 1 2


19) What will the value of x be after the following statements execute? int x; x = 18.0 / 4; A) 4

B) 4.5

C) 0

Answer: B 20) How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28; A) int x, y, z = 7, 16, 28 B) int x = 7, y = 16, z = 28; C) int x = 7 y = 16 z = 28; D) int x = 7; y = 16; z = 28; E) None of these will work. Answer: B

5

D) unknown


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.