CSCI Ch 1 - 7 combined, CSCI CH 8-11, 13-14, Computer Science 165 Midterm, C++ Chapter 12, Ch17, Final

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

E

34) Which of the following is a preprocessor directive? A) pay = hours * rate; B) cin >> rate; C) // This program calculates the user's pay. D) int main() E) #include <iostream>

E

39) Which of the following is a common input device? A) Keyboard B) Mouse C) Scanner D) Microphone E) All of the above

E

9) Of the following, which is a valid C++ identifier? A) June1997 B) _employee_number C) ___department D) myExtraLongVariableName E) All of the above are valid identifiers.

E

3) True/False: In programming, the terms "line" and "statement" always mean the same thing.

FALSE

27) The float data type is considered ________ precision, and the double data type is considered ________ precision. A) single, double B) float, double C) integer, double D) short, long E) None of the above

A

13) During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions? A) fetch B) decode C) execute D) portability stage

A

23) What is the value of cookies after the execution of the following statements? int number = 38, children = 4, cookies; cookies = number % children; A) 2 B) 0 C) 9 D) .5 E) None of these

A

37) Which of the following is not one of the five major components of a computer system? A) Preprocessor B) The CPU (central processing unit) C) Main memory D) Input/Output device E) Secondary storage device

A

7) These are data items whose values do not change while the program is running. A) Literals B) Variables C) Comments D) Integers E) None of the above

A

35) Which of the following defines a double-precision floating point variable named payCheck? A) float payCheck; B) double payCheck; C) payCheck double; D) Double payCheck;

B

11) Besides decimal, two other number systems you might encounter in C++ programs are: A) Octal and Fractal B) Hexadecimal and Octal C) Unary and Quaternary D) Base 7 and Base 9 E) None of the above

B

15) This step will uncover any syntax errors in your program. A) Editing B) Compiling C) Linking D) Executing E) None of these

B

18) A set of well-defined steps for performing a task or solving a problem is known as a(n): A) Hierarchy B) Algorithm C) Central Processing Unit D) Encoded instruction E) None of the above

B

19) This is used to mark the end of a complete C++ programming statement. A) Pound Sign B) Semicolon C) Data type D) Void E) None of the above

B

22) If you use a C++ key word as an identifier, your program will: A) Execute with unpredictable results B) not compile C) understand the difference and run without problems D) Compile, link, but not execute E) None of the above

B

29) Mistakes that cause a running program to produce incorrect results are called: A) Syntax errors B) Logic errors C) Compiler errors D) Linker errors E) None of the above

B

3) Which of the following best describes an operator? A) An operator is a rule that must be followed when constructing a program. B) An operator allows you to perform operations on one or more pieces of data. C) An operator marks the beginning or ending of a statement, or is used to separate items in a list. D) An operator is a word that has a special meaning. E) An operator is a symbolic name that refers to a variable.

B

37) What will the following code display? int number = 7; cout << "The number is " << "number" << endl; A) The number is 7 B) The number is number C) The number is7 D) The number is 0

B

43) What will the value of x be after the following statements execute? int x; x = 18 / 4; A) 4.5 B) 4 C) 0 D) unknown

B

48) Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object? A) name = Jane; B) name = "Jane"; C) name = 'Jane'; D) name = (Jane);

B

12) ________ are used to translate each source code instruction into the appropriate machine language instruction. A) Modules B) Library routines C) Compilers D) Preprocessor directives E) None of the above

C

26) Three primary activities of a program are: A) Variables, Operators, and Key Words B) Lines, Statements, and Punctuation C) Input, Processing, and Output D) Integer, Floating-point and Character E) None of the above

C

30) A variable's ________ is the part of the program that has access to the variable. A) data type B) value C) scope D) reach E) None of the above

C

36) In a broad sense, the two primary categories of programming languages are: A) Mainframe and PC B) Hardware and Software C) Low-level and High-level D) COBOL and BASIC E) None of the above

C

36) What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday"; A) Monday Tuesday Wednesday B) Monday Tuesday Wednesday C) MondayTuesdayWednesday D) "Monday" "Tuesday" "Wednesday"

C

4) The ________ is/are used to display information on the computer's screen. A) Opening and closing braces B) Opening and closing quotation marks C) cout object D) Backslash E) None of the above

C

45) What will the value of x be after the following statements execute? int x; x = 18 % 4; A) 0.45 B) 4 C) 2 D) unknown

C

9) The computer's main memory is commonly known as: A) The hard disk B) The floppy disk C) RAM D) Secondary storage E) None of the above

C

10) The ________ decodes an instruction and generates electrical signals. A) Arithmetic and Logic Unit B) Main memory C) BIOS D) Control Unit E) None of the above

D

12) A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. A) double, single B) triple, double C) open, closed D) single, double E) None of the above

D

14) What statement best describes a variable and its primary purpose? A) A variable is a structured, general-purpose language designed primarily for teaching programming. B) A variable is a collection of eight bits. C) A variable is a word that has a special meaning to the compiler. D) A variable is a named storage location in the computer's memory used for holding a piece of information. E) A variable is a "line" of code in the body of a program, which may change.

D

16) Which data type typically requires only one byte of storage? A) short B) int C) float D) char E) double

D

2) At the heart of a computer is its central processing unit. The CPU's job is: A) To fetch instructions B) To carry out the operations commanded by the instructions C) To produce some outcome or resultant information D) All of the above E) None of the above

D

27) An example of a secondary storage device is: A) The computer's main memory B) The keyboard C) The monitor D) The disk drive E) None of the above

D

3) For every opening brace in a C++ program, there must be a: A) String literal B) Function C) Variable D) Closing brace E) None of the above

D

1) True/False: Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and maintaining computer programs.

TRUE

7) True/False: A CPU really only understands instructions that are written in machine language.

TRUE

38) In the process of translating a source file into an executable file, which of the following is the correct sequence? A) Source code, preprocessor, modified source code, linker, object code, compiler, executable code. B) Preprocessor, source code, compiler, executable code, linker, modified source code, object code. C) Source code, compiler, modified source code, preprocessor, object code, linker, executable code. D) Source code, preprocessor, modified source code, compiler, object code, linker, executable code. E) Source code, linker, object code, compiler, modified source code, preprocessor, executable code.

D

41) What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl; A) Four score and seven years ago B) Four score and seven years ago C) Fourscoreandsevenyearsago D) Fourscore andseven yearsago

D

49) In C++ 11, if you want an integer literal to be treated as a long long int, you can append ________ at the end of the number. A) L B) <INT> C) I D) LL E) None of the above

D

5) The ________ causes the contents of another file to be inserted into a program. A) Backslash B) Pound sign C) Semicolon D) #include directive E) None of the above

D

38) What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; A) 0 1 2 B) 0 1 2 C) xyz D) 012

D

15) What is the modulus operator? A) + B) * C) & D) % E) ||

D

23) The name for a memory location that may hold data is: A) Key Word B) Syntax C) Operator D) Variable E) None of the above

D

29) Which of the following correctly consolidates the following declaration statements into one statement? int x = 7; int y = 16; int z = 28; A) int x = 7; y = 16; z = 28; B) int x = 7 y = 16 z = 28; C) int x, y, z = 7, 16, 28 D) int x = 7, y = 16, z = 28; E) None of these will work.

D

18) In programming terms, a group of characters inside a set of quotation marks is called a(n): A) String literal B) Variable C) Operation D) Statement E) None of the above

A

21) Even when there is no power to the computer, data can be held in: A) Secondary storage B) The Input Device C) The Output Device D) The Algorithm E) None of the above

A

25) A variable declaration announces the name of a variable that will be used in a program, as well as: A) The type of data it will be used to hold B) The operators that will be used on it C) The number of times it will be used in the program D) The area of the code in which it will be used E) None of the above

A

33) This is a set of rules that must be followed when constructing a program. A) Syntax B) Punctuation C) Portability D) Operators E) Key words

A

39) What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; A) Four score and seven years ago B) Four score and seven years ago C) Four score and seven years ago D) Four score and seven years ago

A

44) What will the value of x be after the following statements execute? int x; x = 18.0 / 4; A) 4.5 B) 4 C) 0 D) unknown

A

5) The purpose of a memory address is: A) To identify the location of a byte in memory B) To prevent multitasking C) To obtain an algorithm D) To improve the effectiveness of high-level languages E) None of the above

A

50) In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value. A) auto key word B) #include preprocessor directive C) variable's name D) dynamic_cast key word E) None of the above

A

1) In a C++ program, two slash marks ( // ) indicate: A) The end of a statement B) The beginning of a comment C) The end of the program D) The beginning of a block of code E) None of the above

B

1) What does the term hardware refer to? A) The relative difficulty of programming B) The physical components that a computer is made of C) The way a computer's storage space is organized D) The logical flow of instructions E) None of the above.

B

17) This is used in a program to mark the beginning or ending of a statement, or separate items in a list. A) Separators B) Punctuation C) Operators D) Key Words E) None of the above

B

17) What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl; A) 15 B) 12 C) 63 D) 72 E) None of these

B

21) ________ must be included in any program that uses the cout object. A) Opening and closing braces B) The header file iostream C) Comments D) Escape sequences E) None of the above

B

24) This is a complete instruction that causes the computer to perform some action. A) Line B) Statement C) Variable D) Key Word E) None of the above

B

28) A variable whose value can be either true or false is of this data type. A) binary B) bool C) T/F D) float E) None of the above

B

28) During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then generate an electronic signal? A) fetch B) decode C) execute D) portability stage

B

31) A(n) ________ is the most fundamental set of programs on a computer. A) compiler B) operating system C) application D) utility program E) None of these

B

31) Every complete C++ program must have a ________. A) comment B) function named main C) preprocessor directive D) symbolic constant E) cout statement

B

33) Which one of the following would be an illegal variable name? A) dayOfWeek B) 3dGraph C) _employee_num D) June1997 E) itemsorderedforthemonth

B

35) The programmer usually enters source code into a computer using: A) Pseudocode B) A text editor C) A hierarchy chart D) A compiler E) None of the above

B

40) A(n) ________ is a diagram that shows the logical flow of a program. A) UML diagram B) flowchart C) hierarchy chart D) program schematic E) None of these

B

6) ________ represent storage locations in the computer's memory. A) Literals B) Variables C) Comments D) Integers E) None of the above

B

7) Programmer-defined names of memory locations that may hold data are: A) Operators B) Variables C) Syntax D) Operands E) None of the above

B

8) You must have a ________ for every variable you intend to use in a program. A) purpose B) definition C) comment D) constant E) None of the above

B

32) This control sequence is used to skip over to the next horizontal tab stop. A) \n B) \h C) \t D) \a E) \'

C

40) What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; A) Four score and seven yearsago B) Four score and seven years ago C) Four score and seven/nyearsago D) Four score and seven yearsago

C

42) Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable? A) letter = Z; B) letter = "Z"; C) letter = 'Z'; D) letter = (Z);

C

46) Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" A) 7 B) 14 C) 8 D) 1

C

10) The numeric data types in C++ can be broken into two general categories: A) numbers and characters B) singles and doubles C) integer and floating point D) real and unreal E) None of the above

C

11) A(n) ________ is a set of instructions that the computer follows to solve a problem. A) Compiler B) Linker C) Program D) Operator E) None of the above

C

13) In memory, C++ automatically places a ________ at the end of string literals. A) Semicolon B) Quotation marks C) Null terminator D) Newline escape sequence E) None of the above

C

16) This term refers to the programmer reading the program from the beginning and stepping through each statement. A) Pseudocoding B) Software Engineering C) Desk Checking D) Spot Checking E) None of the above

C

19) The statements written by the programmer are called: A) Syntax B) Object code C) Source code D) Runtime libraries E) None of the above

C

2) A statement that starts with a # symbol is called a: A) Comment B) Function C) Preprocessor directive D) Key word E) None of the above

C

20) Internally, the CPU consists of two parts: A) The Output Device and the Input Device B) The Software and the Hardware C) The Control Unit and the Arithmetic and Logic Unit D) The Single-task Device and the Multi-task Device E) None of the above

C

20) Which character signifies the beginning of an escape sequence? A) // B) / C) \ D) # E) {

C

22) Words that have a special meaning and may be used only for their intended purpose are known as: A) Operators B) Programmer Defined Words C) Key Words D) Syntax E) None of the above

C

25) Character constants in C++ are always enclosed in ________. A) [brackets] B) "double quotation marks" C) 'single quotation marks' D) {braces} E) (parentheses)

C

26) These are used to declare variables that can hold real numbers. A) Integer data types B) Real data types C) Floating point data types D) Long data types E) None of the above

C

30) Computer programs are also known as: A) hardware B) firmware C) software D) silverware E) None of the above

C

32) This is a volatile type of memory, used for temporary storage. A) Address B) ALU C) RAM D) Disk drive E) None of the above

C

34) Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen? A) 13 and 14 B) 8 and 9 C) 14 D) 13 E) 15

C

6) The programming process consists of several steps, which include: A) Input, Processing, and Output B) Key Words, Operators, and Punctuation C) Design, Creation, Testing, and Debugging D) Syntax, Logic, and Error Handling E) None of the above

C

8) Characters or symbols that perform operations on one or more operands are: A) Syntax B) Op codes C) Operators D) Program ops E) None of the above

C

4) An Integrated Development Environment typically consists of: A) A text editor B) A compiler C) A debugger D) All of the above E) None of the above

D

47) The first step in using the string class is to #include the ________ header file. A) iostream B) cctype C) cmath D) string E) None of the above

D

24) This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. A) len B) bytes C) f(x) D) int E) sizeof

E

2) True/False: Pseudocode is a form of program statement that will always evaluate to "false."

FALSE

5) True/False: The preprocessor executes after the compiler.

FALSE

6) True/False: Machine language is an example of a high-level language.

FALSE

8) True/False: Programs are commonly referred to as hardware.

FALSE

10) True/False: The term "bit" stands for binary digit.

TRUE

4) True/False: In C++, key words are written in all lowercase letters.

TRUE

9) True/False: The CPU is the most important component in a computer because without it, the computer could not run software.

TRUE


Conjuntos de estudio relacionados

Senior Project MLA Research Paper Outline (sample paper)

View Set

Chapter 6 Review Data Management

View Set

TERM 4 Ch 28 Care of Patients Requiring Oxygen Therapy or Tracheostomy

View Set

305 Chapter 29 Infection Control

View Set

Technology Resources for Learning (Midterm Study Guide)

View Set