230k views
3 votes
Which of the following statements will cause an error?

x = 17
x = 42 % 7
17 = x
x = '17'

1 Answer

4 votes

Final answer:

The statement x = 17 = x will cause an error because the equal sign (=) should not be used to assign a value to a variable, but to compare two values.

Step-by-step explanation:

The statement that will cause an error is x = 17 = x. In this statement, the equal sign (=) should not be used to assign a value to a variable, but to compare two values. To correctly assign a value to a variable, we use the assignment operator (=) instead.

So, the correct statements would be:

  • x = 17;
  • x = 42 % 7;
  • x = '17';

User Criswell
by
8.5k points