You need to retain the last two values (at least).
The first two values are 2 and 0 (apparently).
So initialize a couple of variables with those values and print them:
Code:
double a = 2, b = 0;
printf("% f\n% f\n", a, b);
Then start your loop at 2, calculate the new value, print it, and then shift the two saved values over:
Code:
for (int n = 2; n < 100; n++) {
double c = -x / n * b - 1.0 / n * (n - 1) * a;
printf("% f\n", c);
a = b;
b = c;
}
Alternatively, you could store all calculated values in an array.
Code:
double a[100] = {2, 0};
for (int n = 2; n < 100; n++)
a[n] = -x / n * a[n-1] - 1.0 / n * (n - 1) * a[n-2];
for (int n = 0; n < 100; n++)
printf("% f\n", a[n]);