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