fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int num = 5, i = 3;
  6. cout << "num = " << num << "; i = " << i << endl;
  7. i = num++ + 2;
  8. cout << "num = " << num << "; i = " << i << endl;
  9.  
  10. cout << "---------------------------------"<< endl;
  11. num = 1;
  12. cout << "before post-increment\t" << num << endl;
  13. cout << "post-increment:\t\t\t" << num++ << endl;
  14. cout << "after post-increment:\t" << num << endl;
  15.  
  16. cout << "---------------------------------"<< endl;
  17. num = 1;
  18. cout << "before pre-increment\t" << num << endl;
  19. cout << "pre-increment:\t\t\t" << ++num << endl;
  20. cout << "after pre-increment:\t" << num << endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
num = 5; i = 3
num = 6; i = 7
---------------------------------
before post-increment	1
post-increment:			1
after post-increment:	2
---------------------------------
before pre-increment	1
pre-increment:			2
after pre-increment:	2