C++ Test prep

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

Suppose that x and y are int variables. Which of the following is a valid input statement? a. cin >> x >> cin >> y; c. cin << x << y; b. cin >> x >> y; d. cout << x << y;

B

Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y) a. false c. 0 b. true d. null

B

The appearance of = in place of == resembles a(n) ____. a. syntax error c. compilation error b. silent killer d. input failure

B

The conditional operator ?: takes ____ arguments. a. two c. four b. three d. five

B

The declaration int a, b, c; is equivalent to which of the following? a. inta , b, c; c. int abc; b. int a,b,c; d. int a b c;

B

To develop a program, you can use an informal mixture of C++ and ordinary language, called ____. a. assert code c. cppcode b. pseudocode d. source code

B

What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout << x << " " << y << " " << z << endl; a. 35 45 80 c. 35 45 -10 b. 35 45 10 d. 35 45 0

B

What is the output of the following statements? cout << setfill('*'); cout << "12345678901234567890" << endl cout << setw(5) << "18" << setw(7) << "Happy" << setw(8) << "Sleepy" << endl; a. 12345678901234567890 ***18 Happy Sleepy b. 12345678901234567890 ***18**Happy**Sleepy c. 12345678901234567890 ***18**Happy Sleepy d. 12345678901234567890 ***18**Happy Sleepy**

B

Which of the following is a relational operator? a. = c. ! b. == d. &&

B

Which of the following will cause a logical error if you are attempting to compare x to 5? a. if (x == 5) c. if (x <= 5) b. if (x = 5) d. if (x >= 5)

B

____ is a valid int value. a. 46,259 c. 462.59 b. 46259 d. -32.00

B

the digit 0 or 1 is called a binary digit, or...

Bit

A sequence of eight bits is called a...

Byte

Choose the output of the following C++ statement: cout << "Sunny " << '\n' << "Day " << endl; a. Sunny \nDay b. Sunny \nDay endl c. Sunny Day d. Sunny \n Day

C

In a ____ control structure, the computer executes particular statements depending on some condition(s). a. looping c. selection b. repetition d. sequence

C

Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____. a. alpha = 5 c. alpha = 50 b. alpha = 10 d. alpha = 50.0

C

Suppose that alpha and beta are int variables. The statement alpha = --beta; is equivalent to the statement(s) ____. a. alpha = 1 - beta; b. alpha = beta - 1; c. beta = beta - 1; alpha = beta; d. alpha = beta; beta = beta - 1;

C

Suppose that alpha and beta are int variables. The statement alpha = beta++; is equivalent to the statement(s) ____. a. alpha = 1 + beta; b. alpha = alpha + beta; c. alpha = beta; beta = beta + 1; d. beta = beta + 1; alpha = beta;

C

Suppose that alpha is an int variable and ch is a char variable and the input is: 17 A What are the values after the following statements execute? cin >> alpha; cin >> ch; a. alpha = 17, ch = ' ' c. alpha = 17, ch = 'A' b. alpha = 1, ch = 7 d. alpha = 17, ch = 'a'

C

Suppose that alpha, beta, and gamma are int variables and the input is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute? cin >> alpha; cin.ignore(100, '\n'); cin >> beta; cin.ignore(100,'\n'); cin >> gamma; a. 100 c. 300 b. 200 d. 320

C

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3;

C

Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3) << x << ' '; cout << setprecision(4) << y << ' ' << setprecision(2) << z << endl; a. 1565.683 85.8000 123.98 c. 1565.683 85.7800 123.98 b. 1565.680 85.8000 123.98 d. 1565.683 85.780 123.980

C

Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(2); cout << x << ' ' << y << ' ' << z << endl; a. 25.67 356.87 7623.96 c. 25.67 356.88 7623.97 b. 25.67 356.87 7623.97 d. 25.67 356.876 7623.967

C

Suppose that x is an int variable and y is a double variable and the input is: 10 20.7 Choose the values after the following statement executes: cin >> x >> y;. a. x = 10, y = 20 c. x = 10, y = 20.7 b. x = 10, y = 20.0 d. x = 10, y = 21.0

C

Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is: 15 76.3 14 Choose the values after the following statement executes: cin >> x >> y >> z; a. x = 15, y = 76, z = 14 b. x = 15, y = 76, z = 0 c. x = 15, y = 76.3, z = 14 d. x = 15.0, y = 76.3, z = 14.0

C

The expression in an if statement is sometimes called a(n) ____. a. selection statement c. decision maker b. action statement d. action maker

C

The programming language C++ evolved from ____.

C

What does <= mean? a. less than c. less than or equal to b. greater than d. greater than or equal to

C

What is the output of the following code fragment if the input value is 4? int num; int alpha = 10; cin >> num; switch (num) { case 3: alpha++; break; case 4: case 6: alpha = alpha + 3; case 8: alpha = alpha + 4; break; default: alpha = alpha + 5; } cout << alpha << endl; a. 13 c. 17 b. 14 d. 22

C

What is the value of x after the following statements execute? int x; x = (5 <= 3 && 'A' < 'F') ? 3 : 4 a. 2 c. 4 b. 3 d. 5

C

When one control statement is located within another, it is said to be ____. a. blocked c. nested b. compound d. closed

C

Which of the following expressions correctly determines that x is greater than 10 and less than 20? a. 10 < x < 20 c. 10 < x && x < 20 b. (10 < x < 20) d. 10 < x || x < 20

C

The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.

CPU

Consider the following C++ program. #include <iostream> using namespace std; int main() { cout << "Hello World " return 0; } In the cout statement, the missing semicolon in the code above will be caught by the ____. a. compiler c. assembler b. editor d. control unit

Compiler

Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent to the statement(s) ____. a. alpha = 1 - beta; b. alpha = beta - 1; c. beta = beta - 1; alpha = beta; d. alpha = beta; beta = beta - 1;

D

Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____. a. sum = 0 c. sum = 10 b. sum = 5 d. sum = 15

D

Suppose that x and y are int variables, ch is a char variable, and the input is: 4 2 A 12 Choose the values of x, y, and ch after the following statement executes: cin >> x >> ch >> y; a. x = 4, ch = 2, y = 12 c. x = 4, ch = ' ', y = 2 b. x = 4, ch = A, y = 12 d. This statement results in input failure

D

Suppose that x is an int variable, ch is a char variable, and the input is: 276. Choose the values after the following statement executes: cin >> ch >> x; a. ch = '2', x = 276 c. ch = ' ', x = 276 b. ch = '276', x = '.' d. ch = '2', x = 76

D

___ consists of 65,536 characters

Unicode

Which of the following is the newline character?

\n

The devices that the computer uses to display results are called ____ devices

output

When the power is switched off, everything in ____ is lost

main memory

Main memory is an ordered sequence of items, called...

memory cells

A(n) ____ consists of data and the operations on those data. a. disk c. interpreter b. compiler d. object

object

Which of the following is a legal identifier? a. program! c. 1program b. program_1 d. program

program_1

Main memory is called...

random access memory

The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____. a. 13 c. 14.8 b. 14 d. 15

13

The length of the string "computer science" is ____. a. 14 c. 16 b. 15 d. 18

16

Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3);

'B'

The programming language C++ was designed by Bjarne Stroustrup at Bell Laboratories in the early ____. a. 1960s c. 1980s b. 1970s d. 1990s

1980s

Suppose that count is an int variable and count = 1. After the statement count++; executes, the value of count is ____. a. 1 c. 3 b. 2 d. 4

2

Which of the following is the "not equal to" relational operator

!=

____ is a valid char value. a. -129 c. 128 b. 'A' d. 129

'A'

The value of the expression 17 % 7 is ____.

3

The value of the expression 33/10, assuming both values are integral data types, is ____. a. 0.3 c. 3.0 b. 3 d. 3.3

3

The expression static_cast<int>(9.9) evaluates to ____. a. 9 c. 9.9 b. 10 d. 9.0

9

Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following expression: z = (y / x > 0) ? x : y;. a. 2 c. 4 b. 3 d. 6

A

Consider the following code. // Insertion Point 1 using namespace std; const float PI = 3.14; int main() { //Insertion Point 2 float r = 2.0; float area; area = PI * r * r; cout << "Area = " << area <<endl; return 0; } // Insertion Point 3 In this code, where does the include statement belong? a. Insertion Point 1 c. Insertion Point 3 b. Insertion Point 2 d. Anywhere in the program

A

Consider the following program segment. ifstream inFile; //Line 1 int x, y; //Line 2 ... //Line 3 inFile >> x >> y; //Line 4 Which of the following statements at Line 3 can be used to open the file progdata.dat and input data from this file into x and y at Line 4? a. inFile.open("progdata.dat"); b. inFile(open,"progdata.dat"); c. open.inFile("progdata.dat"); d. open(inFile,"progdata.dat");

A

Manipulators without parameters are part of the ____ header file. a. iostream c. ifstream b. iomanip d. pmanip

A

Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent to the statement(s) ____. a. beta = beta + 1; alpha = beta; b. alpha = beta; beta = beta + 1; c. alpha = alpha + beta; d. alpha = beta + 1;

A

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin.get(ch1); cin.putback(ch1); cin >> ch2; a. W c. Y b. X d. Z

A

Suppose that ch1 and ch2 are char variables, alpha is an int variable, and the input is: A 18 What are the values after the following statement executes? cin.get(ch1); cin.get(ch2); cin >> alpha; a. ch1 = 'A', ch2 = ' ', alpha = 18 b. ch1 = 'A', ch2 = '1', alpha = 8 c. ch1 = 'A', ch2 = ' ', alpha = 1 d. ch1 = 'A', ch2 = '\n', alpha = 1

A

Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the following statements? cout << fixed << showpoint; cout << setprecision(3); cout << x << ' ' << y << ' ' << setprecision(2) << z << endl; a. 55.680 476.859 23.82 c. 55.680 476.860 23.82 b. 55.690 476.860 23.82 d. 55.680 476.859 23.821

A

Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is: 15A 73.2 Choose the values after the following statement executes: cin >> x >> ch >> y; a. x = 15, ch = 'A', y = 73.2 b. x = 15, ch = 'A', y = 73.0 c. x = 15, ch = 'a', y = 73.0 d. This statement results in an error because there is no space between 15 and A.

A

Suppose that x is an int variable. Which of the following expressions always evaluates to true? a. (x > 0) || ( x <= 0) c. (x > 0) && ( x <= 0) b. (x >= 0) || (x == 0) d. (x > 0) && (x == 0)

A

What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout << y << endl; a. 2 c. 8 b. 5 d. 10

A

What is the output of the following code? char lastInitial = 'A'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl; } a. section 1 c. section 3 b. section 2 d. section 5

A

What is the output of the following code? if (6 > 8) { cout << " ** " << endl ; cout << "****" << endl; } else if (9 == 4) cout << "***" << endl; else cout << "*" << endl; a. * c. *** b. ** d. ****

A

What is the output of the following statements? cout << "123456789012345678901234567890" << endl cout << setfill('#') << setw(10) << "Mickey" << setfill(' ') << setw(10) << "Donald" << setfill('*') << setw(10) << "Goofy" << endl; a. 123456789012345678901234567890 ####Mickey Donald*****Goofy b. 123456789012345678901234567890 ####Mickey####Donald*****Goofy c. 123456789012345678901234567890 ####Mickey####Donald#####Goofy d. 23456789012345678901234567890 ****Mickey####Donald#####Goofy

A

Which of the following operators has the highest precedence? a. ! c. % b. * d. =

A

A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is called a(n) ____. a. algorithm c. analysis b. linker d. design

Algorithm

To develop a program to solve a problem, you start by ____. a. analyzing the problem b. implementing the solution in C++ c. designing the algorithm d. entering the solution into a computer system

Analyzing the problem

_____ programs perform a specific task.

Application

For a program to use the assert function, it must include which of the following? a. #include <assert> c. #include <assertc> b. #include <cassert> d. #include NDEBUG

B

In C++, the dot is an operator called the ____ operator. a. dot access c. data access b. member access d. member

B

In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin >> one >> two; executes, ____. a. one = 10.5, two = 10.5 c. one = 30.6, two = 30.6 b. one = 10.5, two = 30.6 d. one = 11, two = 31

B

Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin >> ch1; ch2 = cin.peek(); cin >> ch2; a. W c. Y b. X d. Z

B

Suppose that outFile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following statements opens the file outputData.out and associates outFile to the output file? a. outFile("outputData.out"); b. outFile.open("outputData.out"); c. open(outFile,"outputData.out"); d. open.outFile("outputData.out");

B

Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z; a. x = 28, y = 32, z = 0.6 b. x = 28, y = 32, z = 12.0 c. x = 28, y = 12, z = 32.6 d. x = 28, y = 12, z = 0.6

B

What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl; } a. section 2 c. section 4 b. section 3 d. section 5

D

When you want to process only partial data, you can use the stream function ____ to discard a portion of the input. a. clear c. delete b. skip d. ignore

D

Which of the following operators has the lowest precedence? a. ! c. && b. || d. =

D

You can disable assert statements by using which of the following? a. #include <cassert> c. #clear NDEBUG b. #define <assert> d. #define NDEBUG

D

____ is a parameterized stream manipulator. a. endl c. scientific b. fixed d. setfill

D

____ represent information with a sequence of 0s and 1s

Digital signals

The term GB refers to...

Gigabyte

A program called a(n) ____ combines the object program with the programs from libraries. a. assembler c. linker b. decoder d. compiler

Linker

A program that loads an executable program into main memory is called a(n) ____. a. compiler c. linker b. loader d. assembler

Loader

Several categories of computers exist, such as...

Mainframe, midsize, and micro

The ____ monitors the overall activity of the computer and provides services.

Operating system

____ are executable statements that inform the user what to do. a. Variables c. Named constants b. Prompt lines d. Expressions

Prompt lines

The ____ rules of a programming language tell you which statements are legal, or accepted by the programming language. a. semantic c. syntax b. logical d. grammatical

Syntax

Which of the following is a reserved word in C++? a. char c. CHAR b. Char d. character

char

A program called a ___ translates instructions written in high level languages into machine code

compiler

An example of a floating point data type is ____. a. int c. double b. char d. short

double

The memory allocated for a float value is ____ bytes. a. two c. eight b. four d. sixteen

four

The devices that feed data and programs into computers are called _____ devices

input

The basic commands that a computer performs are _____, and performance of arithmetic and logical operations.

input, output, storage

Dividing a problem into smaller subproblems is called ____ design. a. OOD c. structured b. top-down refinement d. analog

structured


Conjuntos de estudio relacionados

RN Concept-Based Assessment Level 2 Online Practice B

View Set

Chapter Four: Directors, company officers and members

View Set

EST Essentials - Chapter 1 Concepts

View Set

Chapter 1: The Nurse's Role in a Changing Maternal-Child Health Care Environment

View Set