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`

`*/`

`#include <stdio.h>`

void main()

`{`

int n;

float i, sum, term;

printf("1 + 1 / 2 + 1 / 3 +......+1 / n \n");

printf("Enter the value of n \n");

scanf("%d", &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);

`}`

advertisement

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.**

advertisement

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.