+ 2
Give and Explain the output of the code
int x=10; x++; cout<<x; cout<<x++;
3 Answers
+ 14
int x=10; // x is 10
x++; // x is 11 after this line
cout<<x; // outputs 11
cout<<x++; // outputs x which still is 11 and
// then increments it, after this
// line x will be 12.
+ 6
Line 1 : x = 10
Line 2 : x = 11
Line 3 : Print 11
Line 4 : Print 11 and x = 12 (post increment)
+ 5
let me try đ
,
//declare variable
int x=10; //set the value of x to 10
//increase the value of x by 1 like this (x=x+1) and now the value of x is 11.
x++;
//print out the value of x which is 11.
cout<<x;
//print the value of x again
cout<<x++;
//after the last line of this code the value of x will be increased again because of the post increment (x++) ,so if you print the x again it will print out a number of 12. hope this help đ
đ
đ