Advertisement
dmilicev

two_increment_operators_in_one_command_v1.c

Nov 19th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. /*
  2.  
  3.     two_increment_operators_in_one_command_v1.c
  4.  
  5.     It’s a sequence error and the compiler can choose to do
  6.     whatever it wants with the results.
  7.  
  8.     RULE:
  9.  
  10.     Don’t change the value of a variable more than once
  11.     within the same sequence point.
  12.  
  13. */
  14.  
  15. #include<stdio.h>
  16.  
  17. int main(void)
  18. {
  19.     int x=10;
  20.  
  21.     printf("\n\n     x = %d ", x);
  22.     printf("\n 1.  x, x++     %d   %d ", x, x++);
  23.  
  24.     x=10;
  25.     printf("\n\n     x = %d ", x);
  26.     printf("\n 2.  x, ++x     %d   %d ", x, ++x);
  27.  
  28.     x=10;
  29.     printf("\n\n     x = %d ", x);
  30.     printf("\n 3.  ++x, x     %d   %d ", ++x, x);
  31.  
  32.     x=10;
  33.     printf("\n\n     x = %d ", x);
  34.     printf("\n 4.  x++, x     %d   %d ", x++, x);
  35.  
  36.     x=10;
  37.     printf("\n\n     x = %d ", x);
  38.     printf("\n 5.  x++, x++   %d   %d ", x++, x++);
  39.  
  40.     x=10;
  41.     printf("\n\n     x = %d ", x);
  42.     printf("\n 6.  ++x, ++x   %d   %d ", ++x, ++x);
  43.  
  44.     x=10;
  45.     printf("\n\n     x = %d ", x);
  46.     printf("\n 7.  ++x, x++   %d   %d ", ++x, x++);
  47.  
  48.     x=10;
  49.     printf("\n\n     x = %d ", x);
  50.     printf("\n 8.  x++, ++x   %d   %d \n", x++, ++x);
  51.  
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement