C program to find out the sum of given H.P

source code


#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);
getch();
}

Comments

Popular posts from this blog

8086 STRING MANIPULATION –FIND AND REPLACE A WORD

Animated Circles In C++

C program to find out the sum of series 1 + 2 + …. + n.