Computer Science, asked by luna1994, 3 months ago

Write output of:

int a=2,c=6,b=0;

b=++a---C+C+++++a;

System.out.println(a+b+""+b+c);​

Answers

Answered by BrainlyProgrammer
6

Output:-

  • 1176

Dry-run:

Given:-

  • a=2
  • c=6
  • b=0

First we will solve and find the value of b

  • b= ++a- --C +C++ + ++a

 \sf \: b= \: ++a- \: --C \: +C++ \: + \: ++a \\ b = 3 - 5 + 5 + 4

now a becomes 4  and   c becomes 6

 \therefore \sf  b =  - 2 + 9 \\ \blue{ \boxed{ \orange{\underline{{b = 7}}}}}

Now,

System.out.println(a+b+""+b+c);

Here, output will be 1176.

•How 1176?

>> Because a+b will get added while b+c will get concatenated with a+b just because of the double quotes ("").

In other words, Every thing before double qote will get added while everything after double quotes will get concatenated. If you want to add b+c simply enclose it with brackets.

__

Attachments:
Answered by Rakshitaa007
0

Answer:

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.a=6

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.a=6a++ // a becomes 7

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.a=6a++ // a becomes 7++a // a becomes 8

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.a=6a++ // a becomes 7++a // a becomes 8a-- // a becomes 7

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, sequentially. They are commonly implemented in imperative programming languages like java, c, c++ the increment operator increments the value of the variable by one, and similarly, the decrement operator decrements the value of the variable by one.a=6a++ // a becomes 7++a // a becomes 8a-- // a becomes 7--a // a becomes 6

Similar questions