Exam 2: Flow of Control

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

The if,while and for statements control only one statement.

Free
(True/False)
4.8/5
(37)
Correct Answer:
Verified

True

You want to determine whether time has run out.The following code correctly implements this. !time > limit

Free
(True/False)
4.9/5
(33)
Correct Answer:
Verified

False

Write multiway if-else statements for which the output is "Alarm: Boiler Pressure: TOO HIGH" if the value of the variable boiler_pressure is greater than 1000 (psi),and the output is "Boiler Pressure: TOO LOW" if the value of boiler_pressure is below 100(psi),otherwise the output is "Boiler Pressure: within normal limits."

Free
(Essay)
4.9/5
(45)
Correct Answer:
Verified

if (boiler_pressure > 1000)
cout << "Boiler Pressure: TOO LOW\n";
else if (boiler_pressure < 100)
cout << "Boiler Pressure: TOO LOW\n";
else
cout << "Boiler Pressure: within normal limits.\n";

Which of the following determines the operator that is processed prior to another operator?

(Multiple Choice)
4.8/5
(40)

Assume variables first and second are declared to be double and are initialized.Write a sequence of lines of code that cause the values stored in first and second to be exchanged if the value of first is not less than second.

(Essay)
4.8/5
(44)

If the following code fragment is executed in an otherwise complete and correct program,which expression will be executed? Why? x = 0; If (x = 12) Yes_statement; Else No_statement;

(Multiple Choice)
4.8/5
(41)

Predict the output of the following nested loops: int n = 1; while(n <= 10) { \quad int m = 10; \quad while(m>=1) \quad { \quad\quad cout << n << " times " << m \quad\quad\quad << " = " << n*m << endl; \quad\quad m--; \quad } \quad n++; }

(Essay)
4.7/5
(30)

Given the declaration int x = 0; The following expression causes a divide by zero error: (x !=0)|| (2/x < 1);

(True/False)
5.0/5
(30)

Assume variables first,second,and max are declared to be double and are initialized.Write a sequence of lines of code that cause the larger of the values in first and second to be stored in max.

(Essay)
4.9/5
(45)

The value of count is 0;limit is 10.Evaluate: (count == 0)&&(limit < 20)

(True/False)
4.9/5
(37)

In the expression (j > 0 && j+1 == 10),which operator executes last?

(Multiple Choice)
4.8/5
(42)

Write Boolean expressions that represent the given English expressions.Assume any variables used have been declared and initialized. a)at least one of x or y is odd b)at least one of x or y is non-negative (x is non-negative is written x >= 0) c)The hit is no more than 2.5 units away from target d)x is 1 or x is equal to y e)t is strictly between 3.2 and 3.3

(Essay)
4.8/5
(44)

Write a program that reads in exactly 10 integers and outputs the sum.

(Essay)
4.7/5
(32)

In a do-while loop,a continue statement terminates the loop.

(True/False)
4.7/5
(39)

Explain the programmer's saying from the text,section 2.2,"Garbage in means garbage out."

(Essay)
4.9/5
(32)

Write multiway if-else statements in which letter grades are assigned based a numeric grade based on this "ten point" scheme: if the numeric grade is not less than 90,the letter grade is an A, if the numeric grade is not less than 80,the letter grade is a B, if the numeric grade is not less than 70,the letter grade is C, if the numeric grade is not less than 60,the letter grade is D, otherwise the letter grade is F.

(Essay)
5.0/5
(38)

A break statement is used in loops only.

(True/False)
4.9/5
(36)

The value of count is 0;limit is 10.Evaluate: count == 0 && limit < 20

(True/False)
4.8/5
(42)

Use the condition operator (x?y:z)to write a very compact expression that assigns the maximum of variables n1 and n2 to the variable max.You should assume that any variables you use have been declared and initialized appropriately.

(Essay)
4.8/5
(46)

Consider the if statement: if(condition)yes_clause;else no_clause; Under which of the following circumstances will both the yes_clause and the no_clause will be executed?

(Multiple Choice)
4.8/5
(37)
Showing 1 - 20 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)