Multiple choice technology programming languages

What's wrong? for (int k = 2, k <=12, k++)

  1. the increment should always be ++k

  2. the variable must always be the letter i when using a for loop

  3. there should be a semicolon at the end of the statement

  4. the commas should be semicolons

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In C-style languages, the parts of a for loop header must be separated by semicolons rather than commas. Commas will cause a syntax error. The variable name k and postfix increment k++ are completely valid syntax, and a semicolon should not immediately follow the loop's closing parenthesis.