For the program in Fig. 5.34, state the scope (either function scope, global namespace scope, local scope or function-prototype scope) of each of the following elements:

```
#include
using namespace std;

int cube( int y ); // function prototype

int main()
{
int x;

for ( x = 1; x <= 10; x++ ) // loop 10 times
cout << cube( x ) << endl; // calculate cube of x and output results
} // end main

// definition of function cube
int cube( int y )
{
return y * y * y;
} // end function cube
```

a) The variable x in main.
b) The variable y in cube.
c) The function cube.
d) The function main.
e) The function prototype for cube.
f) The identifier y in the function prototype for cube.

a) block scope.
b) block scope.
c) global namespace scope.
d) global namespace scope.
e) global namespace scope.
f) function-prototype scope.

Computer Science & Information Technology

You might also like to view...

A ________ control displays to the left of a text box control and contains descriptive information, usually the field name

A) parent B) details C) label D) properties

Computer Science & Information Technology

The style rule ul {list-style-image: url(redball.png);} displays items from _____ lists marked with the graphic image in the redball.png file.?

A. ?ordered B. ?unordered C. ?unstructured D. ?structured

Computer Science & Information Technology