What is the number of iterations in the following loop?

```
for (int i = 1; i <= n; i++) {
// iteration
}
```

a. 2*n
b. n
c. n - 1
d. n + 1


b. n
The loop is executed n times for i from 1 to n. So, the correct answer is B.

Computer Science & Information Technology

You might also like to view...

____________________ happens when input applied to a variable is larger than the memory allotted to that variable.

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

Computer Science & Information Technology

Overload the average method of Exercise 5.22 such that if three integers are provided as parameters, the method returns the average of all three.

What will be an ideal response?

Computer Science & Information Technology

A(n) control algorithm executes its instructions in a straight line from top to bottom and then stops. _________________________

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

Computer Science & Information Technology

Item D in the accompany figure names the number of frames it will take the photo to fade.

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

Computer Science & Information Technology