Module 2 Quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

You can use these to override the rules of operator precedence in a mathematical expression. A) [Brackets] B) (Parentheses) C) {Braces} D) The escape character \ E) None of these

B) (Parentheses)

In the following C++ statement, what will be executed first according to the order of precedence?result = 6 - 4 * 2 + 7 - 11 / 2 ; A) 6 - 4 B) 4 * 2 C) 2 + 7 D) 7 - 11 E) 11 / 2

B) 4 * 2

___________reads a line of input, including leading and embedded spaces, and stores it in a string variable? A) cin.get B) getline C) cin D) get E) None of these

B) getline

When a variable is assigned a number that is too large for its data type, it: A) underflows B) overflows C) reverses polarity D) exceeds expectations E) None of the above

B) overflows

You want the user to enter the length, width, and height in the same line from the keyboard separated by spaces. Which cin statement is correctly written? A) cin << length, width, height; B) cin.get(length, width, height); C) cin >> length >> width >> height; D) cin >> length, width, height; E) cin << length; width; height;

C) cin >> length >> width >> height;

Which is NOT true about setw() and/or the following statement?cout << setw(4) << num4 << " "; A) It allows four spaces for the value in the variable num4. B) It needs <iomanip> header to be included. C) setw() works only for numeric variables. D) All of the above are true.

C) setw() works only for numeric variables.

What will the value of result be after the following statement executes?result = 6 - 3 * 2 + 7 - 11 / 2 ; A) 8 B) 6 C) 1.5 D) 2

D) 2

What is the value stored in perGallon, given the statements:int miles = 250, gallons = 12;double perGallon = static_cast<double> (miles) / gallons; A) 20 B) 21 C) 20.5 D) 20.833

D) 20.833

What is the value of avg when this code executes? // This program displays the average of the numbers. #include <iostream> using namespace std; int main() { int num1 = 30, num2 = 20, num3 = 10; double avg; avg = num1 + num2 + num3 / 3; cout << "The average is " << avg << endl; return 0; } A) 10.0 B) 20.0 C) 53.33 D) 53.0 E) 54.0

D) 53.0

Provided proper seed has been used with these statements: unsigned seed = time(0); srand(seed); // Seed the random number generator. The following expression will produce a random number between 1 and 100. A) randomNumber = rand()/ 100; B) randomNumber = 1 + rand() / 100; C) randomNumber = rand()% 100; D) randomNumber = 1 + rand()% 100; E) None of the above

D) randomNumber = 1 + rand()% 100;

The math function in C++ that is used to raise power of a number is _______ .

pow


Kaugnay na mga set ng pag-aaral

Chapter 9 - Financial Planning and Analysis

View Set

Anatomy & Physiology Part 2 Exam 1

View Set

Formation and Elimination of Synapses

View Set

Respiratory (PrepU Ch17+19, Saunders, uWorld)

View Set

VOICE OVER INTERNET PROTOCOL (VoIP) FUNDAMENTALS BCOC D10

View Set