Computer Science, asked by kumarpankaj9565, 4 months ago

solve the expressions int a = 20, b=16, c=30
a-=++a - --b + a%b​

Answers

Answered by anjumalik4128
0

Explanation:

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);

}

}

24th November 2016, 8:34 PM

Aditya kumar pandey

+4

var++ gives the current value first then increments it by 1.

++var increments the value by 1 first then gives its value.

so in your question:

a = 10;

current value of a is 10.

a++ gives the current value first which is 10,

then makes its value 11.

so the current value of a is 11.

++a increments 11 by 1 first,

making a = 12,

then gives its current value which is 12.

so,

b = a++ + ++a

= 10 + 12

= 22

1st January 2017, 10:51 PM

Erwin Mesias

+3

a++ : increment after assign value.

++a : assign value after increment.

Similar questions