programming-examples/c/Series_Programs/Write a c program to find out the sum of given H.P.c
2019-11-15 12:59:38 +01:00

18 lines
345 B
C

#include<stdio.h>
#include<conio.h>
void main() {
int n;
float i, sum, t;
printf("1+1/2+1/3+......+1/n\n");
printf("Enter the value of n\n");
scanf("%d",&
amp;
n);
sum=0;
for (i=1;i<=n;i++) {
t=1/i;
sum=sum+t;
}
printf("%f",sum);
getch();
}