Given the following program segment, what will output to the screen?
int num = 5;
if(num > 5);
cout << "number is greater than five" << endl;
What is number is greater than five?
There are 16 bits in __ bytes of memory.
What is 2?
A ______ variable is designed to store a memory address.
What is a pointer?
The ____ goes above the main function and informs the compiler about the existence of a function before its actual definition.
What is a function prototype?
The ____ function always has the same name as the class.
What is constructor?
What will the following program output?
int magic(int&);
int main() {
int x = 2, y = 4;
cout << x << " " << y << " ";
magic(x);
cout << x << " " << y << " ";
return 0;
}
int magic(int &num) {
int y = 8;
num = 0;
cout << num << " " << y << " ";
return y;
}
What is 2 4 0 8 0 4?
Which statement will read an entire line of input including spaces into the following string object?
string name;
What is getline(cin, name); ?
The & returns the _____ of a variable.
What is the memory address?
Given the following function, what is the return type?
void itsPastMyBedtime(int tiredIndex) {
cout << "I am " << tiredIndex << "/100" << endl;
}
What is void?
The _____ is the part of the code that may not be accessed and used by outside code.
What is the private interface?
Write the programming statement that correctly PRINTS the SECOND ELEMENT of the vector defined below?
vector <int> clocks(8);
What is cout << clocks.at(1) ?
If the variable num was assigned 3.14159265, how would you print the variable out so it prints 3.141?
What is cout << fixed << setprecision(3) << num; ?
Is the following correct syntax for dynamically allocating a Bender array of 100 elements where Bender is a structure (declared below)?
struct Bender
{
string element;
string placeOfOrigin;
bool isBlind;
};
Bender* new benderArray[100];
What is absolutely not?
What is the output of the following program?
void magic(int);
int main() {
int x = 3;
cout << x << " ";
magic(x);
cout << x << " ";
return 0;
}
void magic(int num) {
num = 7;
cout << num << " ";
}
What is 3 7 3?
Look at the following structure declaration:
struct Bender{
string element;
string placeOfOrigin;
};
In this declaration, placeOfOrigin is _____.
What is a member?
What is the output of the following code segment:
void myFunction(int*);
int main() {
int* x;
int num = 2;
x = &num ;
cout << *x << " ";
myFunction(x);
cout << *x;
return 0;
}
void myFunction (int* y) {
*y *= 3;
cout << *y;
}
What is 2 6 6?
Given the program segment below, write the missing programming statement that will read in a string containing spaces from the user, which should be placed in the character array (c-string) named trait.
char vanderCat[50];
cout << "What is the best trait a vanderCat can have?\n";
//missing line goes here
cout << "I agree! " << vanderCat << " would be awesome.\n";
What is cin.getline(vanderCat, 50); ?
struct Bender
{
string element;
bool isBlind;
};
Given the structure declaration above and assume a pointer variable to a Bender has already been created named myBender. Select the correct statement below that would dynamically allocate an array of 100 Bender variables and use myBender to point to it.
What is myBender = new Bender[100];
How many times will the following loop display "Read Carefully"?
int x = 0;
while (x < 10)
cout << "Read Carefully";
x++;
What is infinitely?
_____ are created from abstract data types that encapsulate data and functions together.
What is an object?
struct Cost
{
double bluebookPrice;
double stickerPrice;
};
struct Car
{
string carMake;
string carModel;
int yearModel;
Cost price;
};
Given the structure declarations above and given that there is a 20-element Car array named carLot that has already been defined in the main function, assign 14299 to the bluebookPrice member of the first element in the carLot array.
What is carLot[0].price.bluebookPrice = 14299; ?
When evaluating relational expressions, _____ is always false.
What is zero?
What would the following code segment display to the screen?
int deaths[18] = {59, 130, 87, 182, 246, 540, 1096, 4548};
cout << deaths[0] + *(deaths + 3) - deaths[2] + deaths[9];
The following is a complete C++ program. What will this program display to the screen when it runs?
#include <iostream>
using namespace std;
void something(int[], int);
int main() {
int values[5]={3, 8, 12, 1, 6};
something(values,5);
cout << values[0];
return 0;
}
void something(int vals[], int size){
for(int i=0; i<size - 1; i++)
vals[i] = vals[i]+vals[i+1];
}
What is 11?
The function(s) that do not have a return type are: ____ and ____.
What are constructors and destructors?