we did a similar problem in class but there was a call function where the increment affected something... does it mean that it would count up from 10 and 20 for 5 times...?
Code:
10 21
11 22
12 23
13 24
14 25
Am i going in the right direction?
here is what we did in class...
Code:
#include <stdio.h>
void DisplayNumbers(); // function prototype
int main()
{
int i;
for (i=0; i<10; i++) // call function 10 times
DisplayNumbers();
return 0;
}
////////////////////////////////////////
void DisplayNumbers()
{
int x=0; // new copy of x each call to function
// re-initializing to zero each time it is called
static int y=0; // same copy of y each call to function
// using the value from the last call
printf ("x=%d ", x);
printf ("y=%d\n\n", y);
x++; // increment values of x and y
y++;
}
but y is static..what is the difference?