Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Given the following variable declarations: int num1 = 10, num2 = 20, newNum =

ID: 1807302 • Letter: #

Question

. Given the following variable declarations: int num1 = 10, num2 = 20, newNum = 30; double x = 5.0, y = 8.0; Determine which of the following assignment statements are valid. For each invalid statement, explain why it is invalid. Assume that each statement immediately follows the above variable declarations. a. num1 = 15; b. num2 = num1 - 18; c. num1 = 5; num2 = 2 + 6; num1 = num2 / 3; d. num1 + num2 = newNum; e. x = 12 * num1 - 15.3; f. num1 * 2 = newNum; g. x / y = x * y; h. num2 = num1 % 2.0; i. newNum = static_cast (x) % 5; j. x = x + 5; k. newNum = num1 + static_cast (4.6 / 2);

Explanation / Answer

a. num1 = 15;

it is valid because it overides 10

b. num2 = num1 - 18;

valid

c. num1 = 5; num2 = 2 + 6; num1 = num2 / 3;

not valid because of the above declaration of num2

d. num1 + num2 = newNum;

invalid

valid statement is

newNum = num1 + num2;

e. x = 12 * num1 - 15.3;

valid

f. num1 * 2 = newNum;

invalid.

valid statement is

newNum = num1 * 2;

g. x / y = x * y;

invalid.

h. num2 = num1 % 2.0;

invalid.

i. newNum = static_cast (x) % 5;

Valid

j. x = x + 5; invalid.

k. newNum = num1 + static_cast (4.6 / 2);

Valid

please rate me 1st