C Program to Find Sum of the Series 1/1+ 2/2+ ……1/N

C Program to Find Sum of the Series post providing implementation program that is used to find the sum of specified series in the above using C language syntax.


#include <stdio.h>
void main()
{
double i, s = 0.0;
int n;
printf(“Enter max value in series : “);
scanf(“%d”, &n);
for (i=1 ; i<=n ; i++)
{
s = s + 1/i;
if (i == 1)
printf(“\n 1 +”);
else if (i == n)
printf(” (1 / %.2lf)”, i);
else
printf(” (1 / %.2lf) + “, i);
}
printf(” = %.2lf”, s);
}

Share this