Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
848 views
in Flow of Control by (49.1k points)
closed by

Write programs to find the sum of the following series:

(a)  X - \(\frac{x^2}{2!}\) + \(\frac{x^3}{3!}\) + \(\frac{x^4}{4!}\) + \(\frac{x^5}{5!}\) + \(\frac{x^6}{6!}\)

(b) X + \(\frac{x^2}{2}\) + \(\frac{x^3}{3}\) + ..... + \(\frac{x^n}{n}\)

1 Answer

+1 vote
by (54.8k points)
selected by
 
Best answer

(a) # include <iostream>

using namespace std;

# include <math.h>

# factorial function

long int fact (int n)

{

long int f = 1;

for (int i = 1; i<n;i++)

f* = i;

return f;

}

// main function

int main()

{

int x,y = 1;

float sum = 0;

cout <<"Enter the value for x:";

cin>>x;

for(int i = 1; i<=6; i++)

{

sum = sum + y*((pow(x,1))/fact(i));

y* = -1;

}

cout <<"Sum = "<<Sun<<end1;

cin.get();

return();

}

(b) # include

using namespace std;

# include int main()

{

int M, L;

float sum = 0;

cout > M;

cout << “Enter the number of terms”; cin>>M;

cout << “Enter the number of terms”; cin>>L;

for (int i = 1; i<=m; i++)

sum = Sum + Pow(m,i)/i;

cout <<“Sum= ” << Sum <<end1;

cin.get();

return 0;

}

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...