Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. Most loops are controlled by the value of a special variable called the _____

ID: 3537691 • Letter: 6

Question

6.  Most loops are controlled by the value of a special variable called the ____________.

7. When an if statement contains a compound statement, this compound statement must be bracketed by ________.

8. In the following expression, the ________ operator will be evaluated first. (Think about precedence, left associativity, and level of nesting.)

(x + y) * z > 7 && y == 3

9. The three categories of control structures are: ________________________.

10. The following code segment should read a list of numbers and compute their product. The value 0 is a sentinel. Although the program is syntactically correct, there are several logic errors which cause the program to work incorrectly. Correct these errors.

int product, item;
cout << "Enter numbers to multiply, 0 to stop: " << endl;
while (item == 0)
{
       product *= item;
       cin >> item;
}
cout << "Their product is " << product << endl;

11. If there are no statements in the body of a while loop that can cause the loop-repetition condition to become false, then there will be an infinite loop when the program executes. True or False

12. In a while loop, the loop-control variable must be initialized before the loop. True or False

13. A unique and unusual data value that is placed after all actual data is called a ____________.

14. The condition in the while statement is tested at the end of each pass. True or False

15. The loop-repetition condition can be false before the loop attempts to execute. True or False

A. terminal value
B. sentinel value
C. loop-termination variable D. loop-control variable
E. input value

Explanation / Answer

Ans:6

Most loops are controlled by the value of a special variable called the LOOP CONTROL VARIABLE.


Ans:7

When an if statement contains a compound statement, this compound statement must be bracketed by OPENING AND CLOSING CURLY BRACES.


Ans:8


In the following expression,(x + y) * z > 7 && y == 3, the () operator will be evaluated first AS PARENTHESIS HAS THE HIGHEST PRIORITY LEFT TO RIGHT ASSOCIATIVITY.


(x + y) * z > 7 && y == 3


Ans:9

Flow of control through any given function is implemented with three basic types of control structures:


1.Sequential: default mode. Sequential execution of code statements (one line after another) -- like following a recipe

2.Selection: used for decisions, branching -- choosing between 2 or more alternative paths. In C++, these are the types of selection statements:

if

if/else

switch

3.Repetition: used for looping, i.e. repeating a piece of code multiple times in a row. In C++, there are three types of loops:

while

do/while

for


Ans:10

THE CORRECT CODE IS :

int product=1, item;

cout << "Enter numbers to multiply, 0 to stop: " << endl<<item;

while (item == 0)

{

product *= item;

cin >> item;

}

cout << "Their product is " << product << endl;


Ans:11


FALSE because once the condition of while loop is false it will exit the loop.


Ans:12


TRUE because ,In a while loop, the loop-control variable must be initialized before the loop.


Ans:13


A unique and unusual data value that is placed after all actual data is called A value sentinel.


Ans:14


TRUE, because in case of do-while the condition in the while statement is tested at the end of each pass.


Ans:15


TRUE,The loop-repetition condition can be false before the loop attempts to execute.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote