Write C++ program to find sum of series 1/2+4/5+7/8+……
#include
#include
using namespace std;
int main()
{
int i,n;
float sum=0,x,a=1;
cout<<"1/2+4/5+7/8+......";
cout<<"\n\nHow many terms(ex: 1,2,3...n)?"; cin>>n;
for(i=0;i<n;++i) { x=a/(a+1); sum+=x; a+=3; }
cout<<"\nSum="<<sum;
return 0;
}
The sum of series of a particular number is a mathematical formula used to calculate a particular value. These series are often found in mathematics and are of great use in various fields. A sum of series is also known as a series of partial sums. There are various types of series such as geometric, arithmetic, harmonic, logarithmic, etc. Series of the same type can be formed by adding different numbers.
Series are very important in mathematics and are used to solve complex problems in physics, chemistry, and biology. For example, the distance covered by a falling object is a function of time. The formula for calculating the time taken by a falling object is given by
1/2×(m/s)×(g×m/s^2)=g×t
where g is the acceleration due to gravity, m is the mass of the object, s is the distance travelled by the object in seconds, and t is the time taken for the object to fall from the starting point.
In the above formula, the values of g and m are constant, but the distance s can vary. When the distance s varies, the value of t also varies. Therefore, the time taken by the object to fall from the starting point is also a function of s.
If the distance s is measured in meters, then the formula can be expressed as
1/2×(m/s)×(g×m/s^2)=g×t
Here, the variable t is a function of the variable s.
In the above formula, the distance s is represented by the variable t, and the value of t is a function of the variable s. Hence, the series of the formula is
1/2+4/5+7/8+…=t
The sum of the above series is a function of the variable s. The value of the sum of the series can be calculated by the formula
∑1/2+4/5+7/8+…=s
Here, the variable s is a function of the variable t.
The sum of a series of positive numbers is called a geometric series. For example, the series of 1/2+4/5+7/8+… can be represented as 1/2+4/5+7/8+…=s where the variable s is a function of the variable t.
Similarly, the sum of a series of negative numbers is called an arithmetic series. For example, the series of -1/2-4/5-7/8-… can be represented as -1/2-4/5-7/8-…=s where the variable s is a function of the variable t.