*Which of the following assignment statements are syntactically correct?*

## PHP

*i. $a = -10;*
` `*ii. 10 = $b;*
` `*iii. $a_b = $a_b + 1; *
` `*iv. $a = "COWS";* |
*v. $a = COWS;*
` `*vi. $a + $b = 40; *
` `*vii. $a = 3 $b; *
` `*viii. $a = "true";* |
*ix. $a = true;*
` `*x. $a %= 2;*
` `*xi. $a += 1;*
` `*xii. $a =* 2;* |

## Java, C++, C#

*i. a = -10;*
` `*ii. 10 = b;*
` `*iii. a_b = a_b + 1; *
` `*iv. a = "COWS";* |
*v. a = COWS;*
` `*vi. a + b = 40; *
` `*vii. a = 3 b; *
` `*viii. a = "true";* |
*ix. a = true;*
` `*x. a %= 2;*
` `*xi. a += 1;*
` `*xii. a =* 2;* |

## Visual Basic, Python

*i. a = -10*
` `*ii. 10 = b*
` `*iii. a_b = a_b + 1 *
` `*iv. a = "COWS"* |
*v. a = COWS*
` `*vi. a + b = 40 *
` `*vii. a = 3 b *
` `*viii. a = "true"* |
*ix. a = true*
` `*x. a -= b*
` `*xi. a += 1*
` `*xii. a =* 2* |

###### Solution

**Correct**. It assigns the integer value -10 to variable` a`

.
**Wrong**. On the left side of the assignment operator, only one variable can exist.
**Correct**. It increases variable` a_b`

by one.
**Correct**. It assigns the string (the text) *COWS* to variable` a`

.
**Correct**. It assigns the content of constant COWS to variable` a`

.
**Wrong**. On the left side of the assignment operator, only one variable can exist.
**Wrong**. It should have been written as` a = 3 * b `

(as` $a = 3 * $b`

in PHP).
**Correct**. It assigns the string *true* to variable` a`

.
**Correct**. It assigns the value` true`

to variable` a`

.
**Correct**. This is equivalent to` a = a - b`

(to` $a = $a - $b`

in PHP).
**Correct**. This is equivalent to` a = a + 1 `

(to` $a = $a + 1`

in PHP).
**Wrong**. It should have been written as` a *= 2`

(as` $a *= 2`

in PHP)

## Leave a Reply