206k views
5 votes
Consider the following for loop:

int j, s;
s = 0;
for (j = 1; j < 10; j++)
s = s + j * (j - 1);
In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and the statement that updates the value of s.

1 Answer

4 votes

Final answer:

In this for loop, the loop control variable is j, the initialization statement is j = 1, the loop condition is j < 10, the update statement is j++, and the statement that updates the value of s is s = s + j * (j - 1).

Step-by-step explanation:

In this for loop:

  • The loop control variable is j.
  • The initialization statement is j = 1.
  • The loop condition is j < 10.
  • The update statement is j++.
  • The statement that updates the value of s is s = s + j * (j - 1).

User BlueIceDJ
by
7.7k points