Advertisement
Guest User

Différence post-incrémentation et pré-incrémentation

a guest
Nov 17th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void post_increment(void);
  4. void pre_increment(void);
  5.  
  6. int main(void)
  7. {
  8.     post_increment();
  9.     pre_increment();
  10. }
  11.  
  12. void post_increment(void)
  13. {
  14.     int a = 0;
  15.     int b = 1;
  16.  
  17.     printf("===== TEST POST-INCREMENTATION =====\n");
  18.     a = b++;
  19.  
  20.     printf("Valeur de a : %d\n", a);
  21.     printf("Valeur de b : %d\n", b);
  22. }
  23.  
  24. void pre_increment(void)
  25. {
  26.     int a = 0;
  27.     int b = 1;
  28.  
  29.     printf("===== TEST PRE-INCREMENTATION =====\n");
  30.     a = ++b;
  31.  
  32.     printf("Valeur de a : %d\n", a);
  33.     printf("Valeur de b : %d\n", b);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement