COP3014 Exam 1

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

To write read data from a file, you define an object of the ________ data type. A. ifstream B. fstream C. ofstream D. inputFile

A

What is TRUE about the following statement?cout << setw(4) << num4 << " "; A. It allows four spaces for the value in num4. B. It is incorrect because it should use setw(num4). C. It is incorrect because it should use setw(10). D. It outputs "setw(4)" before the value in num4.

A

What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout << total << endl; A. 13 B. 0 C. 23 D. 3 E. None of these

A

Which of the following must be included in any program that uses the cout object? A. the header file iostream B. opening and closing braces C. comments D. a namespace E. None of these

A

Which value can be entered to cause the following code segment to display the message "That number is acceptable"? int number; cin >> number; if (number > 10 && number < 100) cout << "That number is acceptable.\n"; else cout << "That number is not acceptable.\n"; A.99 B. 10 C. 0 D. 100 E. all of these

A

________ reads a line of input, including leading and embedded spaces, and stores it in a string object. A. getline B. cin.get C. get D. cin.getline E. None of these

A

What is the value of x after the following code executes?int x = 0;int y = 5;int z = 4;x = x + y + z * 2; A. 0 B. 26 C. 13 D. 18 E. unknown

C

What will the following code display? int number = 6; ++number; cout << number << endl; A. 6 B. 5 C. 7 D. 0

C

What will the following code display? int number = 6; cout << ++number << endl; A. 6 B. 5 C. 7 D. 0

C

To allow file access in a program, you must use ________ in the header file. A. #include fstream B. #include file C. #include cfile D. #include fileaccess

A

A character literal is ________, whereas a string literal is ________ A. enclosed in single quotation marks, enclosed in double quotation marks B. enclosed in quotation marks, enclosed in brackets C. enclosed in double quotation marks, enclosed in single quotation marks D. enclosed in brackets, enclosed in quotation marks E. None of these

A

A volatile type of memory that is used for temporary storage is A) RAM B) a disk drive C) an address D) the ALU E) None of these

A

Characters or symbols that perform operations on one or more operands are: A. operators B. op codes C. separators D. key words E. None of these

A

How many times will the following loop display "Hello world!"? for (int i = 0; i < 20; i++) cout << "Hello world!" << endl; A. 20 B. 19 C. 21 D. an infinite number of times

A

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

A

When C++ is working with an operator, it strives to convert operands to the same type. This is known as A. promotion B. type conversion C. type correction D. demotion E. None of these

B

What is the value of number after the following statements execute?int number = 10; number += 5; number -= 2; number *= 3; A. 30 B. 39 C. 2 D. 3 E. None of these

B

What is the value of the following expression? true && !false A. -1 B. true C. false D. 0 E. None of these

B

Associativity is either right to left or A. front to back B. left to right C. top to bottom D. undeterminable E. None of these

B

Something within a while loop must eventually cause the condition to become false or a(n) ________ results. A. compiler error B. infinite loop C. null value D. unexpected exit E. None of these

B

The first step in writing a program is to A)type the code B) clearly define what the program is to do C) visualize the program running on a computer D) visualize logical errors E) None of these

B

This manipulator causes the field to be left justified with padding spaces printed to the right: A. left_pad B. left C. right D. left_justify E. None of these

B

What is assigned to the variable result given the statement below with the following assumptions: x = 10, y = 7, and x, result, and y are all int variables. result = x >= y; A. 0 B. 1 C. x >= y D. 7 E. 10

B

Which statement is equivalent to the following?number = number * 2; A. number * 2 = number; B. number *= 2; C. number = pow(number, 2); D. number = number * number; E. None of these

B

________ are used to translate each source code instruction into the appropriate machine language instruction. A) runtime libraries B) compilers C) preprocessor directives D) modules E) None of these

B

Which of the following functions tells the cin object to skip one or more characters in the keyboard buffer? A. cin.hop B. cin.skip C. cin.ignore D. cin.jump E. None of these

C

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) execute C) decode D) portability

C

If you intend to place a block of statements within an if statement, you must place ________ around the block. A. angle brackets < > B. square brackets [ ] C. curly braces { } D. parentheses( ) E. None of these

C

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n) A. post-test loop B. infinite loop C. null statement D. pre-test loop E. None of these

C

The ________ causes the content of another file to be inserted into a program. A. double slash (//) B. cout object C. #include directive D. semicolon (;) E. None of these

C

The programmer usually enters source code into a computer with A) a compiler B) a hierarchy chart C) a text editor D) pseudocode E) None of these

C

The while loop is a ________ loop. A. limited B. infinite C. pre-test D. post-test E. None of these

C

This is used in a program to mark the beginning or ending of a statement, or separate items in a list: A. key words B. separators C. punctuation D. operators E. None of these

C

This means to increase a value: A. parse B. modulus C. increment D. decrement E. None of these

C

This operator increments the value of its operand and then uses the value in context. A. postfix increment B. postfix decrement C. prefix increment D. prefix decrement E. None of these

C

What is the output of the following code? int w = 98; int x = 99; int y = 0; int z = 1; if (x >= 99) {if (x < 99)cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; } A. 99 B. 0 C. 1 D. 98 E. None of these

C

What is the value of donuts after the following statement executes? int donuts = 10; if (donuts != 10) donuts = 0; else donuts += 2; A. 0 B. 10 C. 12 D. 1 E. None of these

C

A debugging process where you, the programmer, pretend you are a computer and step through each statement while recording the value of each variable at each step is known as A. hand writing B. error checking C.error handling D. hand tracing E. None of these

D

A named storage location in the computer's memory that holds a piece of information is a(n): A) statement B) operator C) key word D) variable E) None of these

D

A variable definition tells the computer A. the variable's data type and its value B. whether the variable is an integer or a floating-point number C. the variable's name and its value D. the variable's name and the type of data it will hold E. None of these

D

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

D

A(n) ________ represents a storage location in the computer's memory. A. literal B. integer C. comment D. variable E. None of thes

D

An Integrated Development Environment (IDE) typically consists of A) a debugger B) a compiler C) a text editor D) All of the above E) None of these

D

Character constants in C++ are always enclosed in A. braces ( { } ) B. brackets ( < > ) C. pound sign and semicolon ( # ; ) D. single quotation marks ( ' ' ) E. Any of these

D

What is the value of result after the following code executes? int a = 60; int b = 15; int result = 10; if (a = b)result *= 2; A. 120 B. 10 C. 12 D. 20 E. code will not execute

D

What is the value of the following expression? true && true A. false B. +1 C. -1 D. true E. None of these

D

Which step uncovers any syntax errors in your program? A) editing B) linking C) executing D) compiling E) None of these

D

You must have a ________ for every variable you intend to use in a program. A. purpose B. literal value C. memory space D. variable definition E. None of these

D

Which of the following statements correctly defines a named constant named TAX_RATE that holds the value 0.075? A. double TAX_RATE = 0.075; B. double TAX_RATE;const TAX_RATE = 0.075; C. const TAX_RATE;double TAX_RATE = 0.075; D. const TAX_RATE = 0.075; E. const double TAX_RATE = 0.075;

E


Conjuntos de estudio relacionados

Lesson 6 - Privacy and Confidentiality

View Set

EXIT HESI - Comprehensive PN Exam A Practice Questions

View Set

Comptia A+ Windows shortcuts and paths

View Set

Trevor Cicala's Security+ Flash Cards

View Set

Ch 20 DNA Tools and Biotechnology

View Set

FIN3403 - Chapter 10, 12, 13, & 14 Concept Questions

View Set

Criminal justice test three chapter 7

View Set