Write output of:
int a=2,c=6,b=0;
b=++a---C+C+++++a;
System.out.println(a+b+""+b+c);
Answers
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
now a becomes 4 and c becomes 6
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.
__
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