C Program to Find the Sum of H.P Series

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);

    }

Share this post


Comments (0)

  • Be first to comment

Leave a comment

or to Comment

Contact Us

  • Address: # 650 Narsi Village Sector 32 Urban Estate Karnal-132001 Haryana, India

  • Phone:(+91) 97289-77666   Email: codethor84@gmail.com


Follow Us