RicardasSim

static

Jul 5th, 2019
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void ppr()
  5. {
  6.     int a = 0;
  7.     static int b = 0;
  8.    
  9.     a++;
  10.     b++;
  11.    
  12.     printf("a = %d, b = %d\n", a, b);
  13. }
  14.  
  15. int main()
  16. {
  17.  
  18.     for(int i = 0; i<10; ++i) ppr();
  19.    
  20.     return 0;
  21. }
  22.  
  23. /*
  24. output:
  25.  
  26. a = 1, b = 1
  27. a = 1, b = 2
  28. a = 1, b = 3
  29. a = 1, b = 4
  30. a = 1, b = 5
  31. a = 1, b = 6
  32. a = 1, b = 7
  33. a = 1, b = 8
  34. a = 1, b = 9
  35. a = 1, b = 10
  36.  
  37. */
Advertisement
Add Comment
Please, Sign In to add comment