+ 2

Give and Explain the output of the code

int x=10; x++; cout<<x; cout<<x++;

5th Apr 2017, 11:42 AM
RaVVan
RaVVan - avatar
3 ответов
+ 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.
5th Apr 2017, 11:59 AM
Tashi N
Tashi N - avatar
+ 6
Line 1 : x = 10 Line 2 : x = 11 Line 3 : Print 11 Line 4 : Print 11 and x = 12 (post increment)
5th Apr 2017, 11:58 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 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 😅😅😅
5th Apr 2017, 12:19 PM
Leon lit
Leon lit - avatar