C++ Chapter 4
This operator represents the logical AND
&&
Given the following code segment, what is output after "result = "? Int x = 1, y = 1, z = 1; Y = y + z; X = x + y; Cout << "result = " << (x < y ? y : x) << endl;
3
If you place a semicolon after the statement: If (x < y)
The complier will interpret the semicolon as null statements.
What is the output of the following code segment? Int x = 5 If (x = 2) Cout << "This is true!" << endl; Else Cout << "This is false!" << end1; Cout << "This all folks!" << endl;
This is true! This is all folks!
True / False: You should be careful when using the equality operator to compare floating point values because of potential round- off errors.
True
True/ False: If the sub-expression on the left side of the || operator is true, the expression on the right side will not be checked.
True
What is the value of the following expression? true && true
True
5. What will the following segment of ode output? Assume the user enters a grade of 90 from the keyboard. Cout << "Enter a test score: "; Cin >> test_score; If (test_score < 60); Cout << "You failed the test!" << endl; If (test_score > 60) Cout << "You passed the test!" << endl; Else Cout << "You need to study for the next test!";
You failed the test! You passed the test!
The default section of a switch statement performs a similar task as the __ portion of an if/else if statement.
trailing else
Which of the following expressions will determine whether x less than or equal to y
x <= y