Answer the following statements true (T) or false (F)

1. Consider two blocks, one within another. If an identifier is declared as a variable in
the inmost of these two blocks, one can access this variable from the outer block.
2. Consider two blocks, one within another. C++ prohibits an identifier to be declared as
a variable in each of these blocks.
3. Calling something a black box is a figure of speech that conveys the idea that you
cannot see inside. You know its behavior and interface but not its implementation.
4. When a loop is nested in side another loop, a break or continue statement
terminates or restarts the outermost loop of the nested loop structure.

1. False:
The scope of a local variable extends from the definition to the end of
the block in which the variable is defined. This excludes the outer block.
2. False
Without the inner variable, the scope of the outer variable would be the
entire outer block, including the inner block. The variable with the inner block for its
scope shadows the outer variable’s scope, making a hole in the scope of the outer
variable.
3. True
If a function is well designed, a client programmer can use it without
knowing the internals. All the programmer needs to know is that if the preconditions
on the arguments are met, all he or she has to do is to name the function and enter the
arguments. The black box will take care of everything else.
4. False
A break or continue terminates or restarts only the innermost loop
containing the break or continue.

Computer Science & Information Technology

You might also like to view...

A ________ such as a calendar is a predesigned file that includes formatting elements and may include some content

A) style B) template C) theme D) layout

Computer Science & Information Technology

Given the following program, which line(s) cause(s) output to be displayed on the screen?

``` 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } ``` a. lines 13 and 14 b. lines 8 and 9 c. line 14 d. lines 14 and 15 e. line 15

Computer Science & Information Technology