What is wrong with the following while repetition statement?

while ( z >= 0 )
sum += z;
What will be an ideal response?


The value of the variable z is never changed in the while statement. Therefore, if the
loop-continuation condition (z >= 0) is initially true, an infinite loop is created. To
prevent the infinite loop, z must be decremented so that it eventually becomes less
than 0.

Computer Science & Information Technology

You might also like to view...

Discuss the impact (and draw an example) of using a sentinel node or dummy node at the head of a list.

What will be an ideal response?

Computer Science & Information Technology

The __________ method will return the current value in the JSpinner.

a) intValue b) getValue c) getNumber d) getCurrentValue

Computer Science & Information Technology

After you save a customized theme of your own making, it can be applied to any presentation.

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

Computer Science & Information Technology

List three interfaces that could be used with a removable data storage unit such as an external hard drive

What will be an ideal response?

Computer Science & Information Technology