What will be the output of the following program segment?
int a = 0, b = 30, c = 40;
a = --b + c++ +b;
System.out.println(“a=”, +a);
Answers
Answered by
1
Answer:
The --b is a pre-decrement operator. It decrements value of B by 1 before calculating.
So, b becomes 29 in calculation.
The c++ is a post increment operator. It increments the value of c by 1 after calculation. So in our case, c still remains 40
So, a= 29+40+29
a=98
So, answer is 98
Explanation:
Similar questions