fork download
  1. #include <stdio.h>
  2. int main(void) {
  3.  
  4. int k; /* simple integer to hold result */
  5. int l; /* simple integer to hold result */
  6.  
  7. l = 5;
  8. printf ("l = %i \n", l++); /* post increment */
  9.  
  10. k = 5;
  11. printf ("k = %i \n", ++k); /* pre increment */
  12.  
  13. /* when implemented by itself, both of these */
  14. /* will just increment these two variables by 1 */
  15.  
  16. printf ("\nBefore: k = %i and l = %i", k, l);
  17. ++l;
  18. k++;
  19.  
  20. printf ("\nAfter: k = %i and l = %i", k, l);
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
l = 5 
k = 6 

Before: k = 6 and l = 6
After: k = 7 and l = 7