This C Program calculates the the sum of H.P series. This program is used to find the sum of the harmonic progression series. Here H.P stands for harmonic progression. Harmonic progression is a progression formed by taking the reciprocals of an arithmetic progression.
Here is source code of the C Program to Find the the sum of H.P series. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Find the Sum of H.P Series
float i, sum, term;
printf("1 + 1 / 2 + 1 / 3 +......+1 / n \n");
printf("Enter the value of n \n");
sum = 0;
for (i = 1; i <= n; i++)
term = 1 / i;
sum = sum + term;
printf("the Sum of H.P Series is = %f", sum);
Output: $ cc pgm23.c $ a.out 1 + 1 / 2 + 1 / 3 +......+1 / n Enter the value of n 5 the Sum of H.P Series is = 2.283334
Sanfoundry Global Education & Learning Series – 1000 C Programs.