include stdio int main int double res double slag printf Input scanf f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
int main() {
int n,k;
double res=0;
double slag=1;
printf("Input N: ");
scanf("%d", &n);
for (k = 1; k <= n; ++k) {
slag*=(-1.)*(n+1)/(n+2);
printf("%lf \n",slag);
res+=slag;
}
printf("res=%lf \n",res);
}