asked 228k views
2 votes
What will be the result of following assignment statement? Assume b = 5 and c = 10.

int a = b * (-c + 2) / 2;
A) 30
B) -30
C) 20
D) -20

1 Answer

4 votes

Final answer:

The value of the expression int a = b * (-c + 2) / 2; given b = 5 and c = 10 evaluates to -20.

Step-by-step explanation:

The result of the assignment statement can be calculated step by step by first evaluating the expression inside the parentheses and then following the order of operations. According to the given values, let's substitute b = 5 and c = 10 into the expression:

int a = b * (-c + 2) / 2;

Now, perform the operation inside the parentheses:

int a = 5 * (-(10) + 2) / 2;

int a = 5 * (-8) / 2;

Next, perform the multiplication:

int a = -40 / 2;

Finally, divide:

int a = -20;

answered
User Plplmax
by
8.9k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.