Program to find sum of 1/2! + 3/4! + 5/6! .... n Terms
//Series: 1/2! + 3/4! + 5/6! ... n terms
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int n, i, j;
float fact=1, sum=0, numerator, denominator;
cout<<"Program to find sum of 1/2! + 3/4! + 5/6! .... n Terms\n";
cout<<"======================================================\n\n";
cout<<"Enter N Terms : ";
cin>>n;
for(i=1;i<=n;i++)
{
numerator=i*2-1;
fact=1;
for(j=1;j<=i*2;j++)
{
fact*=j;
}
denominator=fact;
cout<<numerator<<"/"<<denominator<<" + ";
sum+=(numerator/denominator);
}
cout<<"\b\b = "<<sum<<endl;
}
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int n, i, j;
float fact=1, sum=0, numerator, denominator;
cout<<"Program to find sum of 1/2! + 3/4! + 5/6! .... n Terms\n";
cout<<"======================================================\n\n";
cout<<"Enter N Terms : ";
cin>>n;
for(i=1;i<=n;i++)
{
numerator=i*2-1;
fact=1;
for(j=1;j<=i*2;j++)
{
fact*=j;
}
denominator=fact;
cout<<numerator<<"/"<<denominator<<" + ";
sum+=(numerator/denominator);
}
cout<<"\b\b = "<<sum<<endl;
}
No comments
Post your comments