7.0k views
3 votes
The following is an example of what kind of loop?

int x = 0;
while(x < 10)
x=x + 1;
a counter controlled loop
an infinite loop
a sentinel controlled loop
this code will not compile

2 Answers

6 votes
Step by step equation
User Michael Dz
by
8.3k points
6 votes

Answer:

The answer is "a counter controlled loop".

Step-by-step explanation:

The explanation of the given code as follows:

  • An integer variable x is initialized with 0.
  • Using a while loop to check the condition repeatedly.
  • The loop will execute until the value of x is less than 10 and the incrementing value of x variable by one.
  • It is not an infinite loop.
  • The sentinel controlled loop is used when the coder doesn't know the number of iteration to occur in the loop. In other words, we can say that it is opposite to counter controlled loop.

User Nikhil Wagh
by
8.3k points