In: Computer Science
Write a complete program to sum the following series: (hint: use the for loop)
1 /2 + 1/ 4 + 1 /6 + ⋯ + 1 /100
PS: use C++ language please
Codesnap
Coding
#include <iostream>//header file to incude
using namespace std;
int main()
{
int i = 2;//initilize value of 2 here
double sum=0;//sum here declare
for(i=2;i<=100;i=i+2)//value start here from i=2 to
100 for seriese
{
sum+=(double)1/i;//make total
here
}
cout<<"Sum is ::"<<sum;//sum is here
return 0;
}
Output
if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........