CS 1336.008 Homework 03

¡Supera tus tareas y exámenes ahora con Quizwiz!

A variable cannot be used:

Before it is defined

Arithmetic operators that share the same precedence have right to left associativity. T/F

False

If you want to know the length of the string that is stored in a string object, you can call the object's size member function. T/F

False

In C++, displaying the float number 34.789 with only 2 decimal places of precision will cause an error. T/F

False

The fixed manipulator causes a number to be displayed in scientific notation. T/F

False

The following statement will output $5.00 to the screen: cout << setprecision(5) << dollars << endl; T/F

False

When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive. T/F

False ~ Uses <iomanip>

% requires integers:

For both operands

Floating-point literals can be represented in

-Fixed point (decimal) notation 31.4159 or 0.0000625 -E notation 3.14159E1 or 6.25e-5

When C++ is working with an operator, it strives to convert the operands to the same type. T/F

True

When the fixed manipulator is used, the value specified by the setprecision manipulator will be the number of digits to appear after the decimal point. T/F

True

The statement: cin >> setw(10) >> str; will read up to this many characters into str. Select one: a. Eight b. Eleven c. Ten d. Nine

d. Nine

When using the sqrt function you must include this header file: Select one: a. iomanip b. iostream c. cstring d. cmath e. cstdlib

d. cmath

The floating-data types are:

-float -double -long double

The only difference between the get function and the >> operator is that get reads the first character typed, even if it is a space, tab, or the [Enter] key T/F

True

What value is assigned to x after the following assignment statement is executed? int x = -3 + 4 % 6 / 5; Select one: a. 2 b. 0 c. 1 d. -3

d. -3

The auto key word:

Tells the compiler to determine the variable's data type from the initialization value.

To initialize a variable means:

To assign it a value when it is defined

The cin >> statement will stop reading input when it encounters a newline character. T/F

True

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0; Select one: a. 4.0 b. 2.0 c. 1.5 d. 6.0

a. 4.0

Which line in the following program will cause a compiler error? 1 #include <iostream> 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 } Select one: a. 6 b. 7 c. 8 d. 9 e. No errors

a. 6

Which statement is equivalent to the following? number += 1; Select one: a. number = number + 1; b. number + 1; c. number = 1; d. None of these

a. number = number + 1;

What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2; Select one: a. 18 b. 13 c. Unknown d. 0

b. 13

What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ; Select one: a. 1.5 b. 2 c. 8 d. 6

b. 2

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3; Select one: a. 15 b. 39 c. 3 d. 2

b. 39

Which line in the following program will cause a compiler error? 1 #include <iostream> 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 } Select one: a. 6 b. 7 c. 8 d. 9 e. No error

b. 7

Which statement is equivalent to the following? x = x * 2; Select one: a. x * 2; b. x *= 2; c. x = x * x; d. None of these

b. x*= 2;

Associativity is either right to left or: Select one: a. Top to bottom b. Front to back c. Left to right d. Undeterminable e. None of these

c. Left to right

When converting some algebraic expressions to C++, you may need to insert ________ that do not appear in the algebraic expression. Select one: a. Calculations b. Coercions c. Parentheses d. Exponents

c. Parentheses

The total number of digits that appear before and after the decimal point is sometimes referred to as: Select one: a. floating points b. significant digits c. precisions d. B and C e. None of these

d. B and C (significant digits and precisions)


Conjuntos de estudio relacionados

Chapter 13 APUSH The Rise of Mass Democracy

View Set

GEB 3213 Business Correspondence Quiz

View Set

ATI - Nursing Care During Stages of Labor

View Set

Anthropology 1050 Exam 1 Study Guide Chapter 2

View Set

Missouri Statues, Rules and Regulations Pertinent to Life Only

View Set

Chapter 40: Respiratory Dysfunction (Perry)

View Set

Georgia State University Intro to General Psych Ch. 12 End of the Chapter Test

View Set

Ch 4 Mini Sim on Marketing Research

View Set