You are on page 1of 4

02/07/2020 An Introduction To Programming Through C++ - Course

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

reviewer4@nptel.iitm.ac.in 

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » An Introduction To Programming Through C++

(course)

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc20_cs53/preview) Ask a Question (forum)

Progress (student/home) Mentor (student/mentor)

Week 4 Programming Assignment 1


Course Due on 2020-02-26, 23:59 IST
outline
Write a program that takes as input two numbers n (integer) and x (double), and
prints cos(x) evaluated by taking n terms of the Taylor series (using x0 =0):
How does an 2 4 6
cos(𝑥) = 1 − 𝑥 /2! + 𝑥 /4! − 𝑥 /6!. . .
NPTEL online
course work?
Sample Test Cases
Week 0
Input Output

Week 1 Test Case 1 100 1.3 0.267499

Week 2 Test Case 2 10 1 0.540302

Week 3 Test Case 3 100 1.8 -0.227202

Week 4
The due date for submitting this assignment has passed.
Lecture 8 : As per our records you have not submitted this assignment.
Computing Sample solutions (Provided by instructor)
Mathematical 1 #include <iostream>
Functions Part 2 #define repeat(x) for(int _iterator_i = 0, _iterator_limit = x; _iterat
1 : Taylor 3 #define main_program int main()
4 #include <cmath>
series (unit? 5 using namespace std;
unit=57&lesson=58) 6 main_program{
7 int n;
Lecture 8 : 8 double x;
9 cin >> n >> x;
Computing 10
Mathematical 11 double sum = 1, term = 1;
Functions Part 12
13 for(int i=0; i<n-1; i++){
2 : Numerical 14 // sum : of terms 0 through i
integration 15 // term : ith term, counting from 0.

https://onlinecourses.nptel.ac.in/noc20_cs53/progassignment?name=174 1/4
02/07/2020 An Introduction To Programming Through C++ - Course

(unit? 16 term = - term * x * x/(2*i+2)/(2*i+1);


unit=57&lesson=59) 17 sum = sum + term;
18 }
19 cout << sum << endl;
Lecture 8 : 20
Computing 21 }
Mathematical 22
Functions Part
3 : Bisection
Method (unit?
unit=57&lesson=60)

Lecture 8 :
Computing
Mathematical
Functions Part
4 : Newton
Raphson
Method (unit?
unit=57&lesson=61)

Lecture 9 :
Loops in
various
applications
Part 1 : Loops
in various
applications
brute force
algorithms
(unit?
unit=57&lesson=62)

Lecture 9 :
Loops in
various
applications
Part 2 : Finding
Pythagorean
Triples (unit?
unit=57&lesson=63)

Lecture 9 :
Loops in
various
applications
Part 3 :
Modelling a
system:
bargaining
(unit?
unit=57&lesson=64)

Lecture 9 :
Loops in
various
applications
Part 4 :
Simulating a
water tank
(unit?
unit=57&lesson=65)

https://onlinecourses.nptel.ac.in/noc20_cs53/progassignment?name=174 2/4
02/07/2020 An Introduction To Programming Through C++ - Course

Lecture 9 :
Loops in
various
applications
Part 5 :
Arithmetic on
very large
numbers (unit?
unit=57&lesson=70)

Quiz : Week 4
Quiz
(assessment?
name=173)

Week 4
Programming
Assignment 1
(/noc20_cs53/progassignment?
name=174)

Week 4
Programming
Assignment 2
(/noc20_cs53/progassignment?
name=175)

Download
Videos (unit?
unit=57&lesson=180)

Weekly
Feedback
(unit?
unit=57&lesson=192)

Week 5

Week 6

Week 7

Week 8

Week 9

Week 10

Week 11

Week 12

Text Transcripts

https://onlinecourses.nptel.ac.in/noc20_cs53/progassignment?name=174 3/4
02/07/2020 An Introduction To Programming Through C++ - Course

https://onlinecourses.nptel.ac.in/noc20_cs53/progassignment?name=174 4/4

You might also like