Search Your Keyword

A One Massage for users

C Program BD say you

Hi, If you are new in our blog and to get support about C program, than you must select your level from right side in this blog.Such as, If you want to learn than you select Entry Level for learning and If you are known the basic of C program than you select Solution Level.


Saturday, September 14, 2019

Q7. Write a program in C to determine a nd print the sum of the following harmonic series for a given value of n. Sum = 1+ 1/2 + 2/3 + - - - - - - -1/n.

Write a program in C to determine an harmonic series:-
#include<stdio.h>
#include<conio.h>

void main()
{
int i, n;
float sum = 0;
clrscr();

printf("Enter the value of n: ");
scanf("%d", &n);



printf("1+1/2+1/3+1/4+---------+1/%d",n);

for(i=1; i<=n; i++)
{
sum=sum + (float) 1/i;
}

printf("The sum of the harmonic series = %d", sum);
}

C Program to determine a harmonic series 

harmonic series in C program, Calculate harmonic series in c, c program for harmonic series, harmonic series in c programming language

No comments:

Post a Comment