Quiz 1 Flashcards
double result = 15 / 6;
Given the assignment statement…. What is the value stored in result?
2.0
0
- Nothing, an error occurs. The program will not compile.
2.5
2.0
Recall that the slope formula is.... Assume the variable names
y2,
y1,
x2, and
x1` already exist in your program as integer values.
Which of the following assignment statements would correctly calculate the slope and store it in a floating-point variable called m?
double m = y2 – y1 / x2 – x1;
double m = static_cast<double>(y2 – y1) / (x2 – x1);
double m = static_cast<double>(y2 – y1) / x2 – x1;
double m = (y2 – y1) / (x2 – x1);
double m = static_cast<double>(y2 – y1) / (x2 – x1);
Given the following information: a = 10
and b = 7
.
Which of the following assignment statements will result in the variable answer containing the value true
?
bool answer = a == 12 && b > 7;
bool answer = a == 12 || b >= 7;
bool answer = a == 12 || b > 7;
bool answer = a == 12 && b >= 7;
bool answer = a == 12 || b >= 7;
Assume the following x = 5
, y = 6
, and z = 8
. What is the result of the Boolean Expression: 7 <= x && z > 4
?
true
false
false
Assume all variables have been declared properly and all includes are there.
The following is a valid assignment statement: sqrt(b * b + c * c) = a;
true
false
false
Assume the following, x = 5
, y = 6
, and z = 8
. What is the result of the Boolean Expression: x != 5 || x <= y
true
false
true
Which header file would we need to include to gain access to tools that let us format our output in C++ ?
iomanip
Which of the following statements will correctly set the cout buffer to always display 3 decimal places?
std::fixed; std::setprecision(3);
std::cout << std::fixed;
std::cout << std::setprecision(3);
std::cout << std::fixed << std::setprecision(3);
std::cout << std::fixed << std::setprecision(3);
A variable declared as const
should be initialized to a value because you cannot change it later in the program.
- True
- False
- True
Which header file would we need to include to gain access to cout
and cin
?
iostream
Which header file would we need to include to gain access to useful mathematical functions in C++?
cmath
What is the name and operator used to send get input from cin
?
Extraction Operator >>
The \_\_\_\_\_\_\_\_
marks the beginning of a single line comment in C++.
\\
Which of the following data types uses the most memory?
int
float
char
double
double
C++ is a(n) \_\_\_\_\_\_\_\_\_\_\_\_\_
language.
Compiled/compiler