test2

Ace your homework & exams now with Quizwiz!

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

The devices that feed data and programs into computers are called ____ devices. a. entry c. output b. input d. secondary

B

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

B

Functions that do not have a return type are called ____ functions.

void

The output of the statement: cout << tolower('$') << endl; is ____.

'$'

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout << list[j] << " "; cout << endl;

0 5 10 15 20

Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the index of the array salesData?

0 through 999

What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

34

After the following statements execute, what are the contents of matrix? int matrix[3][2]; int j, k; for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) matrix[j][k] = j + k;

01 12 23

The statement: return 8, 10; returns the value ____.

10

Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? sum = 0; cin >> num; for (int j = 1; j <= 4; j++) { sum = sum + num; cin >> num; } cout << sum << endl;

125

The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.

14

The programming language C++ was designed by Bjarne Stroustrup at Bell Laboratories in the early ____.

1980s

What is the output of the following C++ code?count = 1; num = 25; while (count < 25) { num = num - 1; count++; } cout << count << " " << num << endl;

25 1

What is the value of x after the following statements execute? int x = 5; int y = 30; do x = x * 2; while (x < y);

40

Consider the following statement: double alpha[10][5];. The number of components of alpha is ____.

50

The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

6

The statement: return 37, y, 2 * 3; returns the value ____.

6

Given the following function: int next(int x) { return (x + 1); } what is the output of the following statement? cout << next(next(5)) << endl;

7

The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl; is ____.

8.0

Assume the following. ​ static_cast<int>('a') = 97 static_cast<int>('A') = 65 ​The output of the statement: ​cout << static_cast<int> (tolower('B')) << endl;​ is ____.

98

To use the predefined function tolower, the program must include the header file ____.

<cctype>

The standard header file for the abs(x)function is ____.

<cmath>

// 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 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

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 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

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.2Choose 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

The digit 0 or 1 is called a binary digit, or ____. a. bit c. Unicode b. bytecode d. hexcode

A

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

A

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

A

When the power is switched off, everything in ____ is lost. a. main memory c. hard disks b. secondary storage d. floppy disks

A

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

A

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

A

____ programs perform a specific task. a. Application c. Operating b. System d. Service

A

A sequence of eight bits is called a ____. a. binary digit c. character b. byte d. double

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

Main memory is called ____. a. read only memory c. read and write memory b. random access memory d. random read only memory

B

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); a. 'A' b. 'B' c. 'C' d. '\n'

B

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

B

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

The ____ monitors the overall activity of the computer and provides services. a. central processing unit c. arithmetic logic unit b. operating system d. control unit

B

The term GB refers to ____. a. giant byte c. group byte b. gigabyte d. great byte

B

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

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. 354580 c. 3545-10 b. 354510 d. 35450

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. 354580 c. 3545-10 b. 354510 d. 35450

B

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

B

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

B

Which of the following is the newline character? a. \r c. \l b. \n d. \b

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

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

B

____ consists of 65,536 characters. a. ASCII-8 c. Unicode b. ASCII d. EBCDIC

B

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

B

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

B

A program called a(n) ____ translates instructions written in high-level languages into machine code. a. assembler c. compiler b. decoder d. linker

C

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

C

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

C

Main memory is an ordered sequence of items, called ____. a. pixels c. memory cells b. registers d. addresses

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 AWhat are the values after the following statements execute? cin >> alpha; cin >> ch; a. alpha=17,ch=' ' b. alpha=1,ch=7 c. alpha=17,ch='A' 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 b. 200 c. 300 d. 320

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 is an int variable and y is a double variable and the input is: 10 20.7Choose the values after the following statement executes: cin >> x >> y;.a. x=10,y=20c. x=10,y=20.7b. x=10,y=20.0d. x=10,y=21.0

C

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

C

The devices that the computer uses to display results are called ____ devices. a. exit c. output b. entry d. input

C

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

C

The programmign language C++ evolved from ____.

C

The value of the expression 17 % 7 is ____. a. 1 c. 3 b. 2 d. 4

C

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

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

____ represent information with a sequence of 0s and 1s. a. Analog signals c. Digital signals b. Application programs d. System programs

C

What is the output of the following C++ code?int list[5] = {0, 5, 10, 15, 20}; int j;for (j = 1; j <= 5; j++) cout << list[j] << " "; cout << endl;

Code results in index out-of-bounds

Several categories of computers exist, such as ____. a. microframe, midframe, and miniframe b. midsize, microframe, and mainframe c. mainsize, midsize, and microsize d. mainframe, midsize, and micro

D

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

The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer. a. MM c. RAM b. ROM d. CPU

D

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 b. section 3 c. section 4 d. section 5

D

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

D

A program called a(n) ____ combines the object program with the programs from libraries.

Linker

Which statement below about prototypes and headers is true?

Prototypes end with a semicolon, but headers do not.

Consider the following statement: int alpha[25][10];. Which of the following statements about alpha is true?

Rows of alpha are numbered 0...24 and columns are numbered 0...9.

A variable or expression listed in a call to a function is called the ____.

actual parameter

A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is called a(n) ____.

algorithm

Dividing a problem into smaller subproblems is called ____ design.

analyzing the problem

The basic commands that a computer performs are ____, and performance of arithmetic and logical operations. a. input, file, list c. input, output, storage b. output, folder, storage d. storage, directory, log

b

A function prototype is ____.

c. a declaration, but not a definition

Given the following function prototype: ​int myFunc(int, int);​ which of the following statements is valid? Assume that all variables are properly declared.

cout << myFunc(myFunc(7, 8), 15);

Given the following function prototype: ​double tryMe(double, double); ​which of the following statements is valid? Assume that all variables are properly declared.

cout << tryMe(2.0, 3.0);

Which of the following is a repetition structure in C++?

do...while

____ loops are called posttest loops.

do...while

A(n) ____-controlled while loop uses a bool variable to control the loop.

flag

Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list?

for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl;

When a continue statement is executed in a ____, the update statement always executes.

for loop

A variable listed in a header is known as a(n) ____ parameter. a. actual b. local c. formal d. function

formal

Which of the following statements declares alpha to be an array of 25 components of the type int?

int alpha[25]

Which of the following function prototypes is valid?

int funcExp(int x, float v);

Which of the following function prototypes is valid?

int funcTest(int, int, float);

Given the following function prototype:​ int test(float, char);​ which of the following statements is valid?

int u = test(5.0, '*');

Consider the statement int list[10][8];. Which of the following about list is true?

list has 10 rows and 8 columns.

A program that loads an executable program into main memory is called a(n) ____.

loader

What executes immediately after a continue statement in a while and do-while loop?

loop-continue test

A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____.

n-dimensional array

A(n) ____ consists of data and the operations on those data.

object

Which of the following statements generates a random number between 0 and 50?

srand(time(0)); num = rand() % 50;

Given the function prototype:float test(int, int, int);which of the following statements is legal?

test(7, 14, 23);


Related study sets

RCA 9.6 Practice Quiz Questions (Flash Cards)

View Set

Lecture 5-7: Intro to Neural Networks

View Set

Chapter 42: Drugs Used to Treat Glaucoma and Other Eye Disorders

View Set

Pharmaceutics 2 exam 2- quiz questions

View Set

Pt. 2 Additional Life Provisions Questions

View Set

Hubspot Email Marketing Certification Q's

View Set

TRANSLATION LIST 2.34 - Modal Verbs

View Set

Romeo & Juliet: Most Famous Plays by William Shakespeare

View Set