Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void ppr1()
- {
- int a = 0;
- static int b = 0;
- a++;
- b++;
- printf("ppr1: a = %d, b = %d\n", a, b);
- }
- void ppr2()
- {
- int a = 0;
- static int b = 0;
- a++;
- b++;
- printf("ppr2: a = %d, b = %d\n", a, b);
- }
- int main()
- {
- for(int i = 0; i<2; ++i) ppr1();
- printf("\n");
- for(int i = 0; i<3; ++i) ppr2();
- printf("\n");
- for(int i = 0; i<2; ++i) ppr1();
- printf("\n");
- for(int i = 0; i<3; ++i) ppr2();
- printf("\n");
- return 0;
- }
- /*
- output:
- ppr1: a = 1, b = 1
- ppr1: a = 1, b = 2
- ppr2: a = 1, b = 1
- ppr2: a = 1, b = 2
- ppr2: a = 1, b = 3
- ppr1: a = 1, b = 3
- ppr1: a = 1, b = 4
- ppr2: a = 1, b = 4
- ppr2: a = 1, b = 5
- ppr2: a = 1, b = 6
- */
Advertisement
Add Comment
Please, Sign In to add comment