Given the following code. Will anything be displayed?
z = 130;
if (x++ > 130)
cout << "z is greater than 130.\n";
a. true
b. false
Answers for C++ Course using "Starting out with C++ : from control structures through objects" by Tony Gaddis. 7/8th ed. I used the Pearson myprogramminglab to complete the homework. Here are my solutions/answers for the exercises/labs so please use the test bank as a GUIDE if you're stuck. Let me know if you find a better solution to a problem or any of the programming challenges. Thanks in advance for your support! Send in missing programming challenges to cplusplus.answers@gmail.com
Chapter 5 Quiz Starting Out With C++ 004
What is the difference between prefix and postfix when dealing with statements that do more than incrementing or decrementing?
a. nothing.
b. prefix will increment/decrement BEFORE the variable is used.
c. postfix will increment/decrement BEFORE the variable is used.
d. both will preform the increment/decrement AFTER the variable is used
a. nothing.
b. prefix will increment/decrement BEFORE the variable is used.
c. postfix will increment/decrement BEFORE the variable is used.
d. both will preform the increment/decrement AFTER the variable is used
Chapter 5 Quiz Starting Out With C++ 003
Given that x is 5 in the snippet below. What will be displayed by the cout statement?
x = 5;
cout << x++;
a. 6
b. 7
c. 5
d. 4
x = 5;
cout << x++;
a. 6
b. 7
c. 5
d. 4
Chapter 5 Quiz Starting Out With C++ 002
The first example is _____ mode and the second is _____ mode?
i++, ++j
a. prefix, postfix
b. postfix, prefix
c. post inc, pre inc
d. pre inc, post inc
i++, ++j
a. prefix, postfix
b. postfix, prefix
c. post inc, pre inc
d. pre inc, post inc
Exericse Number
Chapter 05,
Quiz
Chapter 5 Quiz Starting Out With C++ 001
How do you use the increment and decrement operators in C++?
a. x++, x--
b. x = x + 1, x = x -1
c. inc x, dec x
d. both a and b are acceptable
e. answer a, c. One is C language and the other is C++
a. x++, x--
b. x = x + 1, x = x -1
c. inc x, dec x
d. both a and b are acceptable
e. answer a, c. One is C language and the other is C++
Chapter 4 Quiz Starting Out With C++ 047
Can you have two variables with the same name in C++?
a. only if they are in the same scope
b. only if they are in different blocks
c. if one of the variables is in a function
d. heck, I wasn't listening when we went over this. idk
a. only if they are in the same scope
b. only if they are in different blocks
c. if one of the variables is in a function
d. heck, I wasn't listening when we went over this. idk
Chapter 4 Quiz Starting Out With C++ 046
The switch statement lets the value of a variable or expression determine where the program will branch in an if/else statement
a. true
b. false
a. true
b. false
Chapter 4 Quiz Starting Out With C++ 045
Since it takes three operands, the conditional operator is considered a
ternary operator.
a. true
b. false
ternary operator.
a. true
b. false
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 044
Which of the following is an example of a conditional operator?
a.
x > y ? z=1 : z=0;
b.
if (x>y)
z=1
else
z=0;
c.
if x>y then z=1 else z=0
d.
? (x>y) : z=1 : z=0;
a.
x > y ? z=1 : z=0;
b.
if (x>y)
z=1
else
z=0;
c.
if x>y then z=1 else z=0
d.
? (x>y) : z=1 : z=0;
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 043
The conditional operator works like an if/else statement
a. true
b. false
a. true
b. false
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 042
What do the ASCII values 65 through 90 represent?
a. the numbers from 65 through 90 as integers.
b. the characters 'a' through 'z'
c. the characters 'A' through 'Z'
d. the characters '0' through '9'
e. none. ASCII is obsolete and no longer used.
a. the numbers from 65 through 90 as integers.
b. the characters 'a' through 'z'
c. the characters 'A' through 'Z'
d. the characters '0' through '9'
e. none. ASCII is obsolete and no longer used.
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 041
The highest or of precedence in C++ is
a. ||
b. !
c. &&
d. they are all the same. Left to right
a. ||
b. !
c. &&
d. they are all the same. Left to right
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 040
Precedence is not important in C++
a. true
b. false
a. true
b. false
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 039
What does || mean in C++?
a. OR
b. NOT
c. EITHER
a. OR
b. NOT
c. EITHER
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 038
What is the value of the following expression?
true && false
a. true
b. false
c. can't tell
d. the expression makes no sense in C++
true && false
a. true
b. false
c. can't tell
d. the expression makes no sense in C++
Chapter 4 Quiz Starting Out With C++ 037
In C++, the ______ operator reverses the "truth" of an expression. It makes a true expression false and a false expression true.
a. &&
b. !
c. ||
d. reverse()
e. none of the above
a. &&
b. !
c. ||
d. reverse()
e. none of the above
Exericse Number
Chapter 04,
Quiz
Chapter 4 Quiz Starting Out With C++ 036
_____ operators connect two or more relational expressions into one or reverse the logic of an expression?
a. syntax
b. binary
c. logical
d. combinatory
e. answer b and c
a. syntax
b. binary
c. logical
d. combinatory
e. answer b and c
Chapter 4 Quiz Starting Out With C++ 035
What is typically used as a flag in C++
a. a float
b. an integer
c. a bool
d. a register
e. b and c
ab. answer c is typical but answer b is also used by some
ae. none of the above. C++ does not have access to the AX or BX flags of the CPU
a. a float
b. an integer
c. a bool
d. a register
e. b and c
ab. answer c is typical but answer b is also used by some
ae. none of the above. C++ does not have access to the AX or BX flags of the CPU
Subscribe to:
Posts (Atom)