79.9k views
5 votes
How many times will the following for loop execute: for (int
i=-3; abs(i)!=4; ++i) {/*...*/}

User Chrystian
by
8.2k points

1 Answer

7 votes

Final answer:

The for loop will execute 8 times.

Step-by-step explanation:

The for loop will execute a certain number of times until a certain condition is met. In this case, the condition is abs(i) != 4, which means that the absolute value of the variable i is not equal to 4. The loop will continue to execute as long as this condition is true.

Let's analyze the values of i in each iteration:

Therefore, the for loop will execute 8 times.

User Emptyset
by
7.9k points