Professional Documents
Culture Documents
Lab Test 1
Lab Test 1
(1)Write a complete and an efficient C Program that should generate the output as:
Factorial of 0 is 1
Factorial of 1 is 1
Factorial of 2 is 2
Factorial of 3 is 6
Factorial of 4 is 24
Factorial of 20 is
(2) For a real value x, the value of cos(x) can be found using the series expansion for cos(x) as
given below:
x2 x 4 x6
cos ( x )=1− + − +...
2! 4! 6!
Write a C program which accepts a positive integer N and a real value x, the program
should evaluate the cos(x) series for N number of terms. Find value of cos(x) using C library
function and compare the two results, ideally the two results should be same however minor
difference is acceptable in this case.
Execute the program for N = 5, 10, 15, compare the results and show that your results are
converging i.e. result of series evaluation is becoming closer to the result of cos(x).