Chapter 5 Quiz Starting Out With C++ 005

Given the following code.  Will anything be displayed?

z = 130;
if (x++ > 130)
cout << "z is greater than 130.\n";

a. true
b. false

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

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


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

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++

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