Answers 833
D
cout << “0”;
cout << endl;
}
- The following is one possible answer:
for (int x = 100; x<=200; x+=2) - The following is one possible answer:
int x = 100;
while (x <= 200)
x+= 2; - The following is one possible answer:
int x = 100;
do
{
x+=2;
} while (x <= 200);
5.counteris never incremented and the whileloop will never terminate. - There is a semicolon after the loop and the loop does nothing. The programmer
might have intended this, but if counterwas supposed to print each value, it won’t.
Rather, it will only print out the value of the counter after the forloop has com-
pleted. - counteris initialized to 100, but the test condition is that if it is less than 10, the
test will fail and the body will never be executed. If line 1 were changed to int
counter = 5;,the loop would not terminate until it had counted down past the
smallest possible int. Because intis signedby default, this would not be what
was intended.
8.Case 0probably needs a breakstatement. If not, it should be documented with a
comment.
Day 8....................................................................................................................
Quiz ................................................................................................................
- The address-of operator (&) is used to determine the address of any variable.
- The dereference operator (*) is used to access the value at an address in a pointer.
- A pointer is a variable that holds the address of another variable.
- The address stored in the pointer is the address of another variable. The value
stored at that address is any value stored in any variable. The indirection operator
(*) returns the value stored at the address, which itself is stored in the pointer.
32 0672327112_app_d.qxd 11/19/04 12:30 PM Page 833