I would like to know, how do I add the value of the sequence in the variable res
and then print it? for example, enter the value of N
equal to 2 and get the value 2.5 in the output?
#include <stdio.h>
int main (void)
{
int N,i;
float res;
scanf("%d", &N);
for( i = 1 ; i <= N; i++)
{
res = (float)i/((N - i) + 1);
}
printf("%.4f\n", res);
return 0;
}