COP Final Exam

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

In the given code, which statement can be used instead of Statement 1? class sample{ public: Sample(int xValue = 0, int yValue = 0)

(sample1)->show_data();

Which expression evaluates to false if x is 0 and y is 100?

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

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

-1

the numNegative variable counts the number of negative values in the array userVals. What should numNegative be initialize to?

0

What is true for comments?

The compiler does not generate machine code for comments

Which is an essential feature of a while loop having the following form? while(LoopExpression){ loopBody }

The loop should be affected by the LoopBody

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 is a valid function for a function that passes two integers (a,b) as arguments, and returns an integer?

int myFunction(int a, int b)

Which declares two related integer arrays names personName and personAge each with 50 elements.

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

What line of code assigns a char variable

outputGames = *gamesPointer;

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

variables

what expression doubles x?

x *= 2;

A program should computer two times x. Which statement has a logic error?

y = x*x;

What line of code

studentPointer = &userStudent;

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 3 2 4 5? All variables are ints.

245

How many function calls exist in the following code? int Calc1(int a, int b){ return a + b/2; }

3

which expression is evaluated first w = y + 2 + 3 * x + z

3*x

Given myVector initially has 5 elemtns with values 3,4,6,8, and 9. What are the values in myVector after the following? myVector.resize(2);

3,4

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

33,34,35,32

What is the output

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

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

6 6 6 6 .. (infinite loop)

What is output? double myFct(double a, double b){ return (a + b) / 2.0; } int main(){ double x = 3.0;

6.0

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

class

What is true about accessors?

An accessor 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 .

If the input sets int x with 5 and int y with 7, what is the ending value of z? z is declared as a boolean. z = (x>y);

False

What is the output for x=15? switch(x): //output: "First " break; //output "Second "

No match

What is output? class Greet{ public: Greet() };

No output

What is the return type for constructors?

None

The following program generates and error. Why? void PrintSum(int num1, int num2){ cout<<num1 + num2; } int main(){ int y; y = PrintSum(4, 5); return 0; }

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

____ sorting is a sorting algorithm

Selection

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

compiler

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

const int NUM_ITEMS = 5;

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

numSize-1

Given two arrays, which code will output all the arrays' elements, in the order key, item followed by newline? int KeysList[SIZE_LIST];

for(i=0, i < SIZE_LIST; ++i){ cout<<keyList[i]<<", " <<itemsList[i] << endl; }

Which for loop iterate 100 times?

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

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

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

What best describes what is output? Assume v is a large array of ints. int i; int s; s =v[0]; for(i=0, i<N_SIZE; ++i){

min value in v

Which assigns the vector's first element with 99? vector<int> myVector(4);

myVector.at(0) = 99;

Which assigns the vector's last element with 99? vector<int> myVector(15);

myVector.at(14) = 99;

The inFS.open(str) function has a string parameter str that specifies -___

name

Which is an invalid access for the vector

numList.at(x+2)

An identifier can ____.

start with an underscore

If a program compiles without errors, the program is free from ____

syntax errors

The following program generates an error. Why? int userVals[NUM_ELEMENTS]; unsigned int i; userVals[0] = 1;

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

Which assigns the last array element with 20 int userNum[N_SIZE];

userNum[N_SIZE - 1] = 20

what value of x outputs "Junior"

value 56


संबंधित स्टडी सेट्स

Applied Authorities Chapters 1-11

View Set

Quantitative Decision Making in Industry - Test 1

View Set

OS - Appetite/Satiety Regulation

View Set

English 12 test: regional voices

View Set

Behaviour Modification 1 an Introduction

View Set