0

Guys plz explain the ++ prefix and ++postfix to me in c++

21st Feb 2017, 6:47 AM
Debasis nath
Debasis nath - avatar
4 Answers
+ 5
int a = 2; cout<<++a; output will be 3 because it increments it first then it prints it
21st Feb 2017, 6:56 AM
chris
chris - avatar
+ 4
int a = 2; cout<<a++; output will be 2 because first it prints the value of a then it increments it
21st Feb 2017, 6:54 AM
chris
chris - avatar
+ 4
to see that it incremented do this : int a = 2; cout<<a++<<" "<<a; output is: 2 3
21st Feb 2017, 7:04 AM
chris
chris - avatar
0
So it will print only 2, Where can i get the value after the increment is done?
21st Feb 2017, 6:59 AM
Debasis nath
Debasis nath - avatar