COP Exam 3

Ace your homework & exams now with Quizwiz!

In the given code, which statement can used instead of Statement 1?

(sample1)->show_data();

Which expression evaluates false if x is 0 and y is 10?

(x==0) && (y==20)

Which input value causes "Goodbye" to be output next?

-1

The numNegatives variable counts the number of negative values in the array userVals. What should numNegatives be initialized to?

0

Which is true for comments?

The compiler does not generate machine code for comments

The following program generates an error. Why?

The for loop tries to access an index that is out of the arrays valid range

Given two integer arrays origList = [2,3,4,5] and offsetList = [6,7,8,9], which statement prints out the sum of the second element in the origList with the corresponding element in the offsetList?

cout << origList[1] * offsetList[1] << endl;

Which best describes what is output? Assume v is a large array of ints.

first value of v

Which declares two integer related arrays named personName and personAge each with 50 elements?

int personName[50]; int personAge[50];

Which is an invalid access for the vector?

numsList.at(x+2)

What line of code makes the character pointer studentPointer point to the character variable userStudent?

studentPointer = &userStudent;

Which expression doubles x?

x *= 2;

A program should compute two times x. Why statement has a logic error?

y = x*x;

A pointer is a(n) _____ that contains a _____.

variable; memory address

If the input is 12, what is the final value for numItems?

101

Which is not a valid identifier?

1stName

What is the output if the input is 3 2 4 5? All variables are ints.

245

How many function calls exist in the following code?

3

Which expression is evaluated first? w = y + 2 + 3 * x + z;

3*x

Given myVector initially has 5 elements with values 3,4,6,8 and 9. What are the values in myVector after the following?

3,4

Given integer vector itemNumbers has three elements with 33,34,35. What are the values in itemNumbers after the following?

33,34,35,32

What is output?

5****5 25***25 125**125

What is the output if the input if 3 2 1 0?

6 4 2 0

What is output?

6.0

The _____ construct defines a new type to group data and functions to form an object.

class

Which is true about accessors?

An accessory reads a class' data members

Two arrays, itemsNames and itemsPrices, are used to store a list of item names and their corresponding prices. Which is true?

Both arrays should be declared to have the same number of elements

Which item converts a high-level language program to low-level machine instructions?

Compiler

If the input sets int x with 5 and int y with 7, what is the ending value of z? z is declared a boolean.

False

What is the output?

Hello

The inFS.open(str) function has a string parameter str that specifies the ____ of the file to open

Name

What is the output for x = 15?

No match

What is the return type for constructors?

None

The following program generates an error. Why?

PrintSum() has void return type, so cannot be assigned to a variable

_____ sort is a sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly picks the proper next value to move from the unforced part to the end of the sorted part.

Selection

If a program compiles without errors, the program is free from _____.

Syntax errors

Which is an essential feature of a while loop having the following form?

The LoopExpression should be affected by the LoopBody

What value of x outputs "Junior"?

Value 56

In an instruction like z = x + y, the symbols x,y and z are examples of _____.

Variables

Which declaration assigns a variable with 5 such that the value can not be later changed?

const int NUM_ITEMS = 5;

Given two arrays, which code will output all the arrays elements, in the order key, item followed by a newline?

for (i-0); i < SIZE_LIST; ++i) [ cout << keyList[i] << "," << itemList[i] << endl; ]

Which for loop will iterate 100 times?

for (i=0; i < 100; i++)

What XXX will generate 1 3 5 7 8 9 as the output?

numSize-1

For the following function, which is a valid function call? Assume maxValue is an integer?

maxValue = Max(15, Max(35,25));

Which is a valid definition for a function that passes two integers (a,b) as arguments, and returns an integer?

myFunction(int a, int b)

Which assigns the vectors first element with 99?

myVector.at(0) = 99;

Which assigns the vectors last element with 99?

myVector.at(14) = 99;

What line of code assigns a char variable outputGames with the value the gamesPointer points to?

someChar = &gamesPointer;

An identifier can ____.

start with an underscore

Which assigns the last array element with 20.

userNum[N_SIZE - 1] = 20;


Related study sets

Health Policy Provisions, Clauses, and Riders

View Set

Chapter 1 Notes - Chapter Recap Questions

View Set