1/72
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
computer stores a program while it is running
main memory
The purpose of a memory address is:
To identify the location of a byte in memory
A set of well-defined steps for performing a task or solving a problem is known as a(n)
algorithm
In the process of translating a source file into an executable file, what is the correct sequence?
Source code, preprocessor, modified source code, compiler, object code, linker, executable code
An Integrated Development Environment (IDE) typically consists of
text editor, compiler, and debugger
a set of rules that must be followed when constructing a program:
syntax
allows you to perform operations on one or more pieces of data
an operator
Three primary activities of a program are:
input, processing, output
The programming process consists of several steps, which include:
design, creation, testing debugging
What is the first step to writing a program?
clearly defining what the program is to do
Two methods used by C++ to write computer programs are:
procedural programming and object-oriented programming
statement that starts with a hashtag is called a ____________
preprocessor directive
The __________ is(are) used to display information on the computer's screen.
cout object
What must be included in any program that uses the cout object?
the header file iostream
Character constants in C++ are always enclosed in:
single quotation marks
in a cout statement, which of the following will advance the output position to the beginning of the next line?
endl or \n
What will the following code display?
cout << "Four\n" << "score\n";cout << "and" << "\nseven";cout << "\nyears" << " ago" << endl;
four
score
and
seven
years ago
What will the following code display?
cout << "Roses " << "are red";cout << "and " << "violets/n"cout << "are" << "blue" << endl;
Roses are redand violets/nareblue
You must have a _____________ for every variable you intend to use in a program.
variable definition
Which of the following is not a valid C++ identifier?
a. April2018
b. employee_number
c. _1user
d. 1user
c. _luser
What will the following code display?
int x = 23, y = 34, z = 45;
cout << x << y << z << endl;
233445
Which of the following statements correctly assigns the character?
a. letter = M
b. letter = "M";
c. letter = 'M';
d. letter = (M)
c. letter = 'M';
What is the value of number after the following statements execute?
int number;
number = 18 / 4;
4
What is the value of number after the following statements execute?
int number
;number = 18 % 4 + 2;
4
What is output of the following statement?
cout << 4 * (15 / (1 + 3)) << endl;
12
Which part of the following line is ignored by the compiler?
double userName = "janedoe"; // user's name is janedoe
a. "janedoe"
b. user's name is
c. user's name is janedoe
d. //
c. user's name is janedoe
Which of the following statements correctly defines a named constant named TAX_RATE that holds the value 0.075?
a. double TAX_RATE = 0.075;
b. const TAX_RATE;
double TAX_RATE = 0.075;
c. const double TAX_RATE = 0.075;
d. double TAX_RATE;
const TAX_RATE = 0.075;
c. const double TAX_RATE = 0.075;
Which of the following statements will allow the user to enter three values to be stored in variables length,width, and height, in that order?
a. cin << length, width, height;
b. cin.get (height, width, length);
c. cin.get (length, width, height);
d. cin >> length; width; height;
c. cin.get (length, width, height);
__________ reads a line of input, including leading and embedded spaces, and stores it in a
getline
After the following code executes, what is the value of my_value if the user enters 0?
cin >> my_value;
if (my_value > 5)
my_value = my_value + 5;
else if (my_value > 2)my_value = my_value + 10;
else
my_value = my_value + 15
15
logical AND
The && operator used to form a compound Boolean expression
After the following code executes, what is the output if user enters 0?
int x = -1;
cout << "Enter a 0 or 1: ";
cin >> x;
if (x)cout << "true" << endl;
elsecout << "false" << endl;
false
What is assigned to the variable result given the statement below with the following assumptions: x = 10, y= 7, and x, result, and y are all int variables
result = x >= y;
1
If you place a semicolon after the statement:
if (x < y) what will happen?
the compiler will interpret the semicolon as a null statement
When a relational expression is false, it has the value:
0
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 << "That's all, folks!" << endl;
This is true! That's all folks
What is the output of the following code segment if the user enters 90 for the score?
cout << "Enter your test score: ";
cin >> test_score;
if (test_score < 60)
cout << "You failed the test." << endl;
if (test_score > 60)
cout << "You passed the test."
else
cout << "You need to study harder next time." << endl;
You passed the test
What is the output of the following code segment if the user enters 23?
int number;
cout << "Enter a number: ";
cin >> number;
if (number > 0)
cout << "Hi, there!" << endl;
else
cout << "Good-bye." << endl;
Hi, there!
What is the value of donuts after the following statement executes?
int donuts = 10;
if (donuts = 1)
donuts = 0;
else
donuts += 2;
0
How would you express x is less than or equal to y?
x <= y
What will be displayed after the following statements execute?
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;
1 1
What is the value of donuts after the following statement executes?
int donuts = 10;
if (donuts != 10)
donuts = 0;
else
donuts += 2;
12
What is the value of result after the following code executes?
int a = 60;
int b = 15;
int result = 10;
if (a = b)
result *= 2;
20
If you intend to place a block of statements within an if statement, you must place __________ around the block:
curly braces { }
A variable, usually a bool or an int, that signals when a condition exists is known as a(n):
flag
This operator represents the logical OR:
| |
This operator takes an operand and reverses its truth or falsehood:
!
What is the value of the following expression?
true && false
false
What is the value of the following expression?
true && true
true
What is the value of the following expression?
true || false
true
These are operators that add and subtract one from their operands.
++ and --
This operator increments the value of its operand and then uses the value in context.
prefix increment
a control structure that causes a statement or group of statements to repeat.
loop
The two important parts of a while loop are the expression that is tested for a true or false value and:
a statement or block that is repeated as long as the expression is true
Something within a while loop must eventually cause the condition to become false or a(n) __________results
infinite loop
The while loop is a ______________ loop
pre-test
if you place a semicolon after the test expression in a while loop, it is assumed to be a(n):
null statement
When the increment operator precedes its operand, as ++num, the expression is in __________ mode
prefix
A statement that may be used to stop a loop's current iteration and begin the next one is:
continue
A statement that causes a loop to terminate early is a:
break
A variable that is regularly incremented or decremented each time a loop iterates is a:
counter
A special value that marks the end of a list of values is a:
sentinel
What will the following code display?
int number = 6;
int x = 0;
x = number--;
cout << x << endl;
6
What is the output of the following code segment?
n = 1;
while (n <= 5)
cout << n << ' ';
n++
1 1 ... and on forever
In the following statement, which operator is used first?
while (x++ < 10)
<
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
7
What will the following code display?
int number = 6;
cout << number++ << endl;
6
What will the following code display?
int number = 6;
cout << ++number << endl;
7
What will the following code display?
int number = 6;
int x = 0;
Page 13 of 13
x = --number;
cout << x << endl;
5
A for statement contains three expressions: initialization, test, and an:
update
In a for statement, this expression is executed only once:
initialization
You may define a __________ in the initialization expression of a for loop.
variable