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 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...

You can display ____________________ to reveal hidden symbols that indicate paragraph breaks, spaces, and tab stops.

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

Computer Science & Information Technology

Which of the following represents a closing comment tag?

A. --> B. --!> C. //> D. >>

Computer Science & Information Technology

Loop methods are language commands that are part of the set of built-in Ruby language constructions.

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

Computer Science & Information Technology

?Thenavelement is used to group inline elements.

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

Computer Science & Information Technology