+ 7
Why the output is 19?
int main() { int i=4,x; x=++i + ++i + ++i; cout<<x; return 0; }
11 Antworten
+ 8
No one can tell in case of c++.
Different compilers implement multiple pre-increment and post-increment in one statement in different ways.
There is no clear rule how to evaluate multiple increment statements in a single executable line in c++.
Try 10 different compilers and you will get at least 3-5 different outputs.
Java is clear in this case and answer is always 18 for this question.
+ 3
I think
when
++i I=5
++i I=6
then
I+I = 12
then
++i I=7
then I+I+I = 12+7 =19
is this right
+ 2
x = ++I(i = 5) + ++i (i = 6) + ++i(i = 7)
x = 5 + 6 + 7
x = 18
+ 2
@tofik how??
+ 2
initially i=4, then we add ++i(5) to it 3 times, so 4 + 5*3=19
0
I don't know. Maybe x was unset? But it is overwritten anyway. So that's not it.
In Java this outputs 18:
public static void main(String[] args) {
int i=4,x;
x=++i + ++i + ++i;
System.out.println(x);
}
As it is expected for me to sum the 5+6+7.
0
yes the output is 18
0
4+5+6
0
13
0
because is grater than input
- 1
var x = 9 + 10 ;