111k views
1 vote
Declare two variables `i` and `j` of type `int`. Assign `i` the value 2 and `j` the value 3. Then calculate `(i + j)` and `(i = 3)`.

A. `(i + j)` is 5.
B. `i = 3` assigns the value 3 to the variable `i`.
C. `i` is now 3, and `j` is 3.
D. The result of `(i + j)` is 6, and `i` is 3.

User CalvinR
by
8.1k points

1 Answer

5 votes

Final answer:

To declare two variables i and j of type int, assign i the value 2 and j the value 3. Calculate (i + j) and (i = 3). (i + j) is 5 and i = 3 assigns the value 3 to the variable i. Hence the correct answer is option B

Step-by-step explanation:

To declare two variables i and j of type int, you can use the following code:

int i = 2;
int j = 3;

To calculate the sum of i and j, you can use the expression (i + j). In this case, the result will be 5.

The expression (i = 3) is an assignment statement which assigns the value 3 to the variable i. After this statement, the value of i will be 3.

Therefore, the correct statements are:

  1. (i + j) is 5.
  2. i = 3 assigns the value 3 to the variable i.

Hence the correct answer is option B

User Ganesh Krishna
by
8.5k points