Write assignment statements that perform the following operations with the variables a, b, and c. i. Adds 2 to ‘a’ and assigns the result to ‘b’. ii. Multiplies ‘b’ times 4 and assigns the result to ‘a’. iii. Divides ‘a’ by 3.14 and assigns the result to ‘b’. iv. Subtracts 8 from ‘b’ and assigns the result to ‘a’.

Respuesta :

Answer:

(i) b = a + 2;

(ii) a = b * 4;

(iii) b = a / 3.14;

(iv) a = b - 8;

Explanation:

Assumptions and comments;

=> The code has been written in Java.

=> The variable a, b and c have been declared.

=> The variable c has only been declared but not used since it is not part of the assignment procedures.

Explanation:

The following is the assignment statement that;

(i) Adds 2 to ‘a’ and assigns the result to ‘b’

To add a number to another number or variable, the arithmetic operator (+) is used using the following syntax;

[number] [+] [other number]

In our case, the number is variable a and the other number is 2. Therefore, to add these numbers together we write;

a + 2;

Also, assignment in programming languages is done using the (=) operator. For example to assign a number k to a variable m, we write;

m = k

In our case, the result (a + 2) from above is assigned to variable b as follows;

=> b = a + 2

(ii) Multiplies ‘b’ times 4 and assigns the result to ‘a’.

To multiply a number by another number or variable, the arithmetic operator (*) is used using the following syntax;

[number] [*] [other number]

In our case, the number is variable b and the other number is 4. Therefore, to multiply these numbers we write;

b * 4;

Also,

In our case, the result (b * 4) from above is assigned to variable a as follows;

=> a = b * 4

(iii) Divides ‘a’ by 3.14 and assigns the result to ‘b’.

To divide a number by another number or variable, the arithmetic operator (/) is used using the following syntax;

[number] [/] [other number]

In our case, the number is variable a and the other number is 3.14. Therefore, to divide these numbers we write;

a / 3.14;

Also,

In our case, the result (a / 3.14) from above is assigned to variable b as follows;

=> b = a / 3.14

(iv) Subtracts 8 from ‘b’ and assigns the result to ‘a’.

To subtract a number from another number or variable, the arithmetic operator (-) is used using the following syntax;

[other number] [-] [number]

In our case, the number is 8 and the other variable is b. Therefore, to subtract these numbers we write;

b - 8;

Also,

In our case, the result (b - 8) from above is assigned to variable a as follows;

=> a = b - 8;