Computer Science, asked by aksharash1995, 1 month ago

Guess the output
public class Increment Decrement
Quiz
{
public static void main(String[] args)
{
int a=11, b=22, C;
C = a + b + a-- + + + + + + a + ++b:
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("c="+c);
}
}​

Answers

Answered by yashichauhan1302
1

Answer:

a=11

b=23

C=78

Explanation:

Your question has extra '+' before the third appearance of 'a'. If we consider 3 '+' only, the value of C comes out to be 78.

Attachments:
Answered by probrainsme104
0

Answer:

The output after running this code is that a is 13,b is 24 and c is 103.

Explanation:

Increment and decrement operators in Java also are referred to as unary operators because they treat one operand. The increment operator (++) adds 1 to its operand and therefore the decrement operator (–) subtracts one.

Given a=11,b=22.

It is also only if c=a+b+a+++b+++++a+++b.

Now, we'll substitute the values within the above expression, we get

c=11+22+(a is used before the increment)+(b is used before the increment)+(a is used after increment)+(bis used after decrement).

a is used before increment means one is added to a, i.e.

a=a+1\\a=11+1\\a=12

b  is used before increment means one is added to b, we get

b=b+1\\b=22+1\\b=23

a is used after increment means one is added to a, i.e.

a=a+1+1\\a=11+2\\a=13

b  is used after increment means one is added to b, we get

b=b+1+1\\b=22+2\\b=24

Then we get

c=11+22+11(a=12,b=22)+22(a=11,b=23)+13(a=13,b=23)+24(a=13,b=24)\\c=11+22+11+22+13+24\\c=103

and a=13,b=24  

#SPJ3

Similar questions