Math, asked by shalini777thakur, 10 months ago

Evaluate java expression,int a =20. when a+ = ++a + --a + a - (10/2) + a++​

Answers

Answered by Abhis506
2

Well, its 22. Try it yourself before down voting this answer. From first term of the expression

b=a++ + ++a;

a++ means 10 but it will increase it value if it is use again.

++a means increase value of a immediately. What is value of a. It is 10, no it will change it value by 1 if it use again. So from above line its value is 11 and than increase value of a immediately its value is 12.  

So value of b = 22.

Use this below code

public class Program

{

   public static void main(String[] args) {

       int a=10,b;

       b= a++ + ++a;

       System.out.println(b);

   }

}

Similar questions