54.4k views
1 vote
State whether it is infinite loop, finite loop, no loop at all, or compiler error.

for (;;) cout << "wow";
A. Infinite loop
B. Finite loop
C. No loop at all
D. Compiler error

1 Answer

4 votes

Final answer:

The code snippet 'for (;;) cout << "wow";' represents an infinite loop because it lacks any termination conditions, causing it to run indefinitely. In this case, the loop has no initialization, condition, or increment expressions specified.

Step-by-step explanation:

The code snippet you provided is an example of a for loop in C++ programming. The syntax of a for loop is typically for (initialization; condition; increment). In this case, the loop has no initialization, condition, or increment expressions specified, which means the loop will run indefinitely unless broken by some other means, such as a 'break' statement or an external event like a program shutdown. Therefore, the correct answer to this question is:

A. Infinite loop

User Ilium
by
8.4k points