The following code compiled, but while running it the program appears to hang (e.g. nothing happens). This is a sign that there may be an infinite loop. What part of this code fragment may be causing an infinite loop?

```
while(i < 50); {
System.out.println(i);
i+=2;
}
```

There is a misplaced semi-colon after the while statement. This causes the loop to have an empty body,
meaning that the i variable is never updated. This leads to an infinite loop.

Computer Science & Information Technology

You might also like to view...

A(n) ________ network allows visitors to access the Internet through a LAN but doesn't allow them to access other resources and data on the network.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

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

1) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. 2) A set of statements contained within a pair of parentheses is called a block. 3) A selection statement specifies that an action is to be repeated while some condition re-mains true. 4) A nested control statement appears in the body of another control statement. 5) C# provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.

Computer Science & Information Technology