New Want to Write for Computaholics ? if Yes Contact us at "contact@computaholics.in"

Program to display sum of series 1+1/2+1/3+……….+1/n

Wrire a Program to display sum of series 1+1/2+1/3+……….+1/n:-

Enter any no: 5
1 + 1/2 + 1/3 + 1/4 + 1/5

Sum=1/15

#include<stdio.h>

void main()
{
int n,i,sum=0;

printf("Enter any no:\n ");
scanf("%d",&n);

printf("1+");

for(i=2;i<=n-1;i++)
printf("1/%d +",i);

for(i=1;i<=n;i++)
sum=sum+i;

printf("1/%d",n);
printf("\nSum=1/%d",sum+1/n);
}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics