CSUSM CS111

An operator allows you to perform operations on one or more pieces of data.
Which of the following best describes an operator?
Program
A(n) ________ is a set of instructions that the computer follows to solve a problem.
We will write a custom essay sample on
CSUSM CS111
or any similar topic only for you
Order now
A variable is a named storage location in the computer’s memory used for holding a piece of information.
What statement best describes a variable and its primary purpose?
Algorithm
A set of well-defined steps for performing a task or solving a problem is known as a(n):
Secondary storage
Even when there is no power to the computer, data can be held in:
The type of data it will be used to hold
A variable declaration announces the name of a variable that will be used in a program, as well as:
Input, Processing, and Output
Three primary activities of a program are:
A text editor
The programmer usually enters source code into a computer using:
A. Keyboard
B. Mouse
C. Scanner
D. Microphone
What is a common input device?
flowchart
A(n) ________ is a diagram that shows the logical flow of a program.
a. June1997
b. _employee_number
c. ___department
d. myExtraLongVariableName
What is a valid C++ identifier?
3dGraph
What would be an illegal variable name?
MondayTuesdayWednesday
What will the following code display?

cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";

The number is number
What will the following code display?

int number = 7;

cout << "The number is " << "number" << endl;

012
What will the following code display?

int x = 0, y = 1, z = 2;

cout << x << y << z << endl;

Four

score

and

seven

years ago

What will the following code display?

cout << "Fourn" << "scoren"; cout << "and" << "nseven"; cout << "nyears" << " ago" << endl;

Four score and seven/nyearsago
What will the following code display?

cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl;

Fourscore

andseven

yearsago

What will the following code display?

cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl;

8
Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy?

“William”

(Hint: Answer this question carefully. Refer to slide 40. Each character requires one byte. What are the essential characters that must be stored in the memory for a typical string?.

double payCheck;
What defines a double-precision floating point variable named payCheck?
23
What will the value of x be after the following statements execute?

int x;

x = 3 + 10 * (16%7) + 2 / 4 ;

3.5
What will the value of x be after the following statements execute?

double x;

x = 3.0 / 6 + 18 / (15 % 4 + 2);

1
What will the value of x be after the following statements execute?

int x;

x = 24/(1 + 2%3 + 4/5 + 6 + 31%8);

letter = ‘Z’;
Assume that a program has the following variable definition:

char letter;

What statement correctly assigns the character Z to the variable?

name = “Jane”;
Assume that a program has the following string object definition:

string name;

What statement correctly assigns a string literal to the string object?

What is the value stored at x, given the statements:

int x;

x = 3 / static_cast (4.5 + 6.4);

3 * 2
In the following C++ statement, what will be executed first according to the order of precedence?

result = 6 – 3 * 2 + 7 – 10 / 2;

—3
Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed?
c = pow(a, 3) / (pow(b, 2) * pow(k, 4));
Write the C++ expression for the following algebraic expression.

c = (a^3)/((b^2)(k^4))

20
What will the value of x be after the following statements execute?

x = (19 − 3) * (2 + 3) / 4

4.0
What is the value of average after the following code executes?
double average;

average = 1.0 + 2.0 + 3.0 / 3.0;

cin.get(length, width, height);
You want the user to enter the length, width, and height from the keyboard. What is the correct can statement?
39
What is the value of number after the following statements execute?

int number = 10;

number += 5;

number -= 2;

number *= 3;

6
Which line in the following program will cause a compiler error?
1 #include

2 using namespace std;

3

4 int main()

5 {

6 const int MY_VAL;

7 MY_VAL = 77;

8 cout << MY_VAL << endl; 9 return 0; 10 }

7
Which line in the following program will cause a compiler error?
1 #include

2 using namespace std;

3

4 int main()

5 {

6 const int MY_VAL = 77;

7 MY_VAL = 99;

8 cout << MY_VAL << endl; 9 return 0; 10 }

15
After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time?
cin >> input_value;

if (input_value > 5)

input_value = input_value + 5;

else if (input_value > 2)

input_value = input_value + 10;

else

input_value = input_value + 15;

false
What will be the output of the following code segment after the user enters 0 at the keyboard?
int x = -1;

cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x;

if (x)

cout << "true" << endl; else cout << "false" << endl;

This is true!
This is all folks!
What is the output of the following code segment?

int x = 5;

if (x = 2)

cout << "This is true!" << endl; else cout << "This is false!" << endl; cout << "This is all folks!" << endl; Hint: answer this question carefully. The way a programmer enters indentation might be wrong. So indentations do not show the exact way a program executes. Remember that if your "if" or "else" condition contains more than one statement, you should enclose them in brackets to make a block. Otherwise not all the statements execute. Refer to slide ch4-17.

You failed the test!
You passed the test!
What will the following segment of code output?
Assume the user enters a grade of 90 from the keyboard.

cout << "Enter a test score: "; cin >> test_score;

if (test_score < 60); cout << "You failed the test!" << endl; if (test_score > 60)

cout << "You passed the test!" << endl; else cout << "You need to study for the next test!"; Hint1: answer this question carefully. What happens when there is a ";" right at the end of an "if" condition? Hint2: The way a programmer enters indentation might be wrong. So indentations do not show the exact way a program executes.

That’s a high score!
This is a test question!
What will the following segment of code output?

score = 40;

if (score > 95)

cout << "Congratulations!n"; cout << "That's a high score!n"; cout << "This is a test question!" << endl; Hint: answer this question carefully. The way a programmer enters indentation might be wrong. So indentations do not show the exact way a program executes. Remember that if your "if" condition contains more than one statement, you should enclose them in brackets to make a block. Otherwise not all the statements execute. Refer to slide ch4-17.

3 and 4 are false.
Assuming x is 5, y is 6, and z is 8, which of the following is false?
1. x == 5;

2. 7 <= (x + 2); 3. z < = 4; 4. (1 + x) != y; 5. z >= 8;

6. x >= 0;

7. x <= (y * 2)

C++ is fun
What will the following segment of code output if the value 11 is entered at the keyboard?
int number;

cin >> number;

if (number > 0)

cout << "C++"; else cout << "Soccer"; cout << " is "; cout << "fun" << endl;

1 1
What will the following program segment display?
int funny = 7, serious = 15;

funny = serious % 2;

if (funny != 1)

{

funny = 0;

serious = 0;

}

else if (funny == 2)

{

funny = 10;

serious = 10;

}

else

{

funny = 1;

serious = 1;

}

cout << funny << " " << serious << endl;

0 1 1 0
What will the following program display?
#include

using namespace std;

int main()

{

int a = 0, b = 2, x = 4, y = 0;

cout << (a == b) << " "; cout << (a != b) << " "; cout << (b <=x) << " "; cout << (y > a) << endl; return 0; }

3
Given the following code segment, what is output after “result = “?

int x = 1, y = 1, z = 1;

y = y + z;

x = x + y;

cout << "result = " << (x < y ? y : x) << endl;

if (code == ‘C’)

cout << "This is a checkn";

What statement allows you to properly check the char variable code to determine whether it is equal to a “C” and then output “This is a check” and then advance to a new line?
12
What is the value of donuts after the following code executes?
int donuts = 10;

if (donuts != 10)

donuts = 0;

else

donuts += 2;

1
What is the output of the following code?
int w = 98;

int x = 99;

int y = 0;

int z = 1;

if (x >= 99)

{

if (x < 99) cout << y << endl; else cout << z << endl; } else { if (x == 99) cout << x << endl; else cout << w << endl; }

99
Which value can be entered to cause the following code segment to display the message:
“That number is acceptable.”
int number;

cin >> number;

if (number > 10 && number < 100) cout << "That number is acceptable.n"; else cout << "That number is not acceptable.n";

8
Which line in the following program will cause a compiler error?
1 #include

2 using namespace std;

3

4 int main()

5 {

6 int number = 5;

7

8 if (number >= 0 && <= 100) 9 cout << "passed.n"; 10 else 11 cout << "failed.n"; 12 return 0; 13 }

<
Look at the following statement.

while (x++ < 10) Which operator is used first?

1 1 1… and on forever
What is the output of the following code segment?

n = 1;

while (n <= 5) cout << n << ' '; n++;

0
1
2
3
4
What will the following loop display?

int x = 0;

while (x < 5) { cout << x << endl; x++; }

6
What will the following code display?
int number = 6;

cout << number++ << endl;

7
What will the following code display?
int number = 6;

cout << ++number << endl;

6
What will the following code display?
int number = 6;

int x = 0;

x = number–;

cout << x << endl;

3
What will the following code display?

int x = 0;

for (int count = 0; count < 3; count++) x += count; cout << x << endl;

19
How many times will the following loop display “Hello”?
for (int i = 1; i < 20; i++) cout << "Hello!" << endl;
21
How many times will the following loop display “Hello”?
for (int i = 0; i <= 20; i++) cout << "Hello!" << endl;
20
How many times will the following loop display “Hello”?

for (int i = 20; i > 0; i–)

cout << "Hello!" << endl;

break;
This statement may be used to stop a loop’s current iteration and begin the next one.
7
What will the following code display?
int number = 6;

number++;

cout << number << endl;

7
What will the following code display?
int number = 6;

++number;

cout << number << endl;

5
What will the following code display?
int number = 6

int x = 0;

x = –number;

cout << x << endl;

fstream
To allow file access in a program, you must #include this header file
outFile << number;
Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?
opened
A file must be ________ before data can be written to or read from it.
4
2
What is the output of the following program?
#include

using namespace std;

void showDub(int);

int main()

{

int x = 2;

showDub(x);

cout << x << endl; return 0; } void showDub(int num) { cout << (num * 2) << endl; }

2
0
2
What is the output of the following program?
#include

using namespace std;

void doSomething(int);

int main()

{

int x = 2;

cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int num) { num = 0; cout << num << endl; }

2
0
0
What is the output of the following program?

#include

using namespace std;

void doSomething(int&);

int main()

{

int x = 2;

cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int& num) { num = 0; cout << num << endl; }

4
Which line in the following program contains the prototype for the showDub function?

1 #include

2 using namespace std;

3

4 void showDub(int);

5

6 int main()

7 {

8 int x = 2;

9

10 showDub(x);

11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 }

15
Which line in the following program contains the header for the showDub function?

1 #include

2 using namespace std;

3

4 void showDub(int);

5

6 int main()

7 {

8 int x = 2;

9

10 showDub(x);

11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 }

10
Which line in the following program contains a call to the showDub function?

1 #include

2 using namespace std;

3

4 void showDub(int);

5

6 int main()

7 {

8 int x = 2;

9

10 showDub(x);

11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 }

3
Look at the following function prototype.
int myFunction(double, double, double);

How many parameter variables does this function have?

7
What is the output of the following program?
#include

using namespace std;

int getValue(int);

int main()

{

int x = 2;

cout << getValue(x) << endl; return 0; } int getValue(int num) { return num + 5; }

computeValue(10);
Here is the header for a function named computeValue:
void computeValue(int value)

Which of the following is a valid call to the function?

1 6 3
Given the following function definition:
void calc (int a, int& b)

{

int c;

c = a + 2;

a = a * 3;

b = c + a;

}

What is the output of the following code fragment that invokes calc?

int x = 1;

int y = 2;

int z = 3;

calc(x, y);

cout << x << " " << y << " " << z << endl;

name
To pass an array as an argument to a function, pass the ________ of the array.
one
A two-dimensional array can have elements of ________ data type(s).
a. strings of the same length
b. strings of different lengths
c. uninitialized elements
A two-dimensional array of characters can contain ________.
string names[5];
An array of string objects that will hold 5 names would be declared using which statement?
4
What is the last legal subscript that can be used with the following array?
int values[5];
1000
How many elements does the following array have?
int bugs[1000];
55
What will the following code display?
int numbers[] = {99, 87, 66, 55, 101 };

cout << numbers[3] << endl;

87
66
55
What will the following code display?
int numbers[] = { 99, 87, 66, 55, 101 };

for (int i = 1; i < 4; i++) cout << numbers[i] << endl;

What will the following code display?

int numbers[4] = { 99, 87 };

cout << numbers[3] << endl;

An error will occur when the code runs
What will the following code do?
const int SIZE = 5;

double x[SIZE];

for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; }

vector v;
Which statement correctly defines a vector object for holding integers?
vector n { 10, 20 };
Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20?
It creates a vector object with a starting size of 10.
What does the following statement do?
vector v(10);
3
5
What will the following C++ 11 code display?
vector numbers { 3, 5 };

for (int val : numbers)

cout << val << endl;

It creates a vector object with a starting size of 10 and all elements are initialized with the value 2.
What does the following statement do?
vector v(10, 2);
push_back
This vector function is used to insert an item into a vector.
size
This vector function returns the number of elements in a vector.
pop_back
This vector function removes an item from a vector.
empty
This vector function returns true if the vector has no elements.
True
true/False: A vector object automatically expands in size to accommodate the items stored in it.
semicolon
This is required after the closing brace of the structure declaration.
will store the character ‘t’ in the fourth element of the publisher member of booklist[2]
Look at the following statement.
bookList[2].publisher[3] = ‘t’;

This statement ________.

by reference
When a structure is passed ________ to a function, its members are not copied.
guarantees not to result in changes to the structure’s members
Passing a structure as a constant reference parameter to a function ________.
takes a Circle structure as a parameter, does something, and returns a Circle structure
If Circle is a structure tag, the statement:
Circle doSomething(Circle c2)

can be the header line for a function that ________.

employee[2].hourlyWage = 100.00;
Which of the following assigns a value to the hourlyWage member of employee[2]?
cout << student[1].gpa;
Which of the following statements outputs the value of the gpa member of element 1 of the student array?
1
Look at the following declaration.
enum Tree { OAK, MAPLE, PINE };

In memory, what value will the MAPLE enumerator be stored as?

True
True/False: It is possible for a structure variable to be a member of another structure variable.
False
Look at the following structure declaration.
struct Circle

{

double centerX;

double centerY;

double radius;

};

Assume that circle1 and circle2 are variables of the Circle type, and their members have been initialized.
True/False: The following if statement correctly determines whether the two variables’ members contain the same data:
if (circle1 == circle2)

×

Hi there, would you like to get such a paper? How about receiving a customized one? Check it out