387,840 views
25 votes
25 votes
4. In the below program, find the error and its location. Then, state the type of the error.

number = 5;
for (counter = -1; counter < number; counter = counter + 1;)
{
write("The counter is " + counter + ".");
}
A.The string inside the write statement is missing a quotation mark. This is a syntax error.
The variable counter is initialized incorrectly. This is a run-time error.
The update counter = counter + 1; in the loop has an extra semicolon. This is a syntax error.
The condition counter < number is written incorrectly. This is a logic error.
(1 point)

User Jagan K
by
2.7k points

1 Answer

9 votes
9 votes

Answer:

The update counter = counter + 1; in the loop has an extra semicolon. This is a syntax error

User Bagbyte
by
2.6k points