The factorial of non-negative integer n is written n! and is defined as follows:

n! = n * (n – 1) * (n – 2) . …. .1 (for values of n greater than or equal to 1).

and

n! = 1 (for n =0).

Perform the following:

a) Write a C program that reads a non-negative integer and computes
and prints its factorial.

b) Write a C program that estimates the value of the mathematical
constant e by using the formula:

e = 1 + 1/1! + 1/2! + 1/3! + …..

c) Write a C program that computes the value e^{x} by using
the formula

ex= 1 + x/1! + x^{2}/2! + x^{3}/3! + …..

For
Free solutions click here

Q2: Write a program to print this triangle:

*

**

*

****

*

******

*

********

*

**********

Don't use ten printf statements; use two nested loops instead. You'll
have to use braces around the body of the outer loop if it contains
multiple statements.

Q3:The standard library contains a function called atoi, which takes a string (presumably a string of digits) and converts it to an integer. For example, atoi(“345”) would return the integer 345. Write a program that reads lines (using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. Also compute the standard deviation.

Q4: Write the function int countchtr(char string[ ], int ch);

which returns the number of times the character ch appears in the
string.

For example, the call countchtr(“She lives in NEWYORK”,
‘e’)

would return 3.

Q5: Write a program that takes three variables (a, b, c) in as separate parameters and rotates the values stored so that value a goes to b, b, to c and c to a.