225k views
0 votes
Determine the value of a and b at the end of the following code segment:

int a = 5;
int b = 10;
a++;
b*=a;
a = b + b;

The value stored for a is _____ and the value stored for b is _____

User Rsturim
by
3.9k points

2 Answers

9 votes

Answer:

a = 120 and b = 60

Step-by-step explanation:

a++ means a = a+1

b*=a is the same as b= a*b

After plugging in the variables,

Here are the results in order:

a = 6;

b = 60;

a = 120;

We only keep the nearest declared value of the variable, so "a" would equal 120 and "b" would equal 60.

User Sumama Waheed
by
5.0k points
0 votes

Answer:

15 and b is 20

Step-by-step explanation:

User Korteee
by
4.3k points