Assume this code fragment is embedded in an otherwise correct and complete program. What should be the output from this code segment?

```
{
for( int i = 0; i < 10; i++)
{
. . .
}
cout << i << endl;
}
```

a) 10
b) 9
c) 0
d) The variable i is undefined in this scope, so this should not compile

d) The variable i is undefined in this scope, so this should not compile

The question is what the output should be, so the correct answer is d). The actual answer depends on what the compiler writer did. On several of my compilers I get 10. Behavior pre ISO C++ is that the variable i is defined in the outer scope shown here.

Computer Science & Information Technology

You might also like to view...

Sections can be used with column formatting

Indicate whether the statement is true or false

Computer Science & Information Technology

What is ergonomics?

What will be an ideal response?

Computer Science & Information Technology