Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

Program to calculate sum of terms of 1/n i.e. 1/n + 2/n + 3/n and so on till n/n

Posted By: Adelhard Fischer     Category: C Programming     Views: 12041

Write a program to calculate sum of terms of 1/n i.e. 1/n + 2/n + 3/n and so on till n/n.

Code for Program to calculate sum of terms of 1/n i.e. 1/n + 2/n + 3/n and so on till n/n in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    float sum,n,term;
    int   count = 1;
clrscr();
    sum = 0;
    printf("Enter value of n\n");
       scanf("%f",&n);
    term = 1.0/n;
    while(count<=n)
    {
       sum = sum + term;
       count++;
    }
    printf("Sum = %f\n",sum);
getch();
}
  
Share: 



Adelhard Fischer
Adelhard Fischer author of Program to calculate sum of terms of 1/n i.e. 1/n + 2/n + 3/n and so on till n/n is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!