+ 2

When does post increment operation takes place .Does it increment immediately or directly in print statement ?

3rd Aug 2017, 5:30 PM
Sowmya Reddy
Sowmya Reddy - avatar
5 odpowiedzi
+ 3
a = 1 print(a++) //Output = 1 print(a) //Output = 2 a = 1 print(++a) // Output = 2 print (a) //Output = 2
3rd Aug 2017, 5:39 PM
Slak
Slak - avatar
+ 3
In the final answer, in either pre incrementing or post incrementing, the final result is (x+1) if x is input. But, printf("x++"); gives x and printf("++x"); gives (x+1) as output .
10th Aug 2017, 5:06 PM
CSK
+ 2
it doesn't take place immediately. ...it is postponed to the next expression and not the print statement. suppose int b=5; int a=b++; cout <<a;//out put=5 but if c=++a; cout <<c;//out put=7
5th Aug 2017, 7:29 PM
Shanoor Afreen
Shanoor Afreen - avatar
0
by " not in print "statement I meant..... immediate print statement( in the above post I already sent)
5th Aug 2017, 7:34 PM
Shanoor Afreen
Shanoor Afreen - avatar
0
thanks afreen for the explanation .
10th Aug 2017, 5:01 PM
Sowmya Reddy
Sowmya Reddy - avatar