Write a C program to determine the sum of the following harmonic series for a given value of N. 1/12 + 2/22 + 3/32 + ……….. + n/n2.
Write a C program to determine the sum of the following harmonic series
for a given value of N.
1/12 + 2/22 + 3/32 +
……….. + n/n2.
Problem name:
Write a C program to determine the sum of the following harmonic series
for a given value of N.
1/12 + 2/22 + 3/32 +
……….. + n/n2.
Algorithm:
Step 1: Start
Step 2: Input the value of N
Step 3: Initialized i=1
Step 4: While i<=n repeat step 5
Step 5: sum=sum+(i+i/i), i++
Step 6: Print the sum is
Step 7: End
C Program:
#include<stdio.h>
int main()
{
int n,i;
float t,sum=0.0;
printf ( “ Input
an Integer Number : “);
scanf("%d",&n);
for
(i=1;i<=n;i++)
{
t=i*i;
sum=i+(i/t);
}
printf("%f",sum);
return 0;
}
লেবেলসমূহ: C_programming
0টি মন্তব্য:
একটি মন্তব্য পোস্ট করুন
এতে সদস্যতা মন্তব্যগুলি পোস্ট করুন [Atom]
<< হোম