fork download
  1. #include <stdio.h>
  2. int main(void) {
  3.  
  4. int k; /* simple integer to hold result */
  5. int n; /* simple integer to hold result */
  6.  
  7. n = 5;
  8. printf ("n = %i \n", n++); /* 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 n = %i", k, n);
  17.  
  18. ++n;
  19. k++;
  20.  
  21. printf ("\nAfter: k = %i and n = %i", k, n);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
n = 5 
k = 6 

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