0% found this document useful (0 votes)
41 views1 page

Lab Test 1

The document describes two C programs: (1) A program that calculates and prints the factorial of integers from 0 to 20. (2) A program that evaluates the cosine series for a real value x for N terms, compares the result to the cosine function from the C library, and shows the results converging as N increases from 5 to 15 terms.

Uploaded by

m.umair iftikhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views1 page

Lab Test 1

The document describes two C programs: (1) A program that calculates and prints the factorial of integers from 0 to 20. (2) A program that evaluates the cosine series for a real value x for N terms, compares the result to the cosine function from the C library, and shows the results converging as N increases from 5 to 15 terms.

Uploaded by

m.umair iftikhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab Test 1

March 07, 2019

(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).

You might also like