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
1.write a c program that reads a non-negative integer and
computes and prints its factorial.
2. write a C program that estimates the value of the
mathematical constant e by using the formula:
e=1+1/!+1/2!+1/3!+....
3. write a c program the computes the value ex by using the
formula
ex=1+x/1!+xsquare/2!+xcube/3!+....
Answer Posted / dally
#include<stdio.h>
int main()
{
int i,n,sum =0;
printf("Enter value for n\n");
scanf("%d",&n);
sum = sum+1/fact(i);
printf("sum of Total result %d",sum);
}
int fact(int j)
{
int k =1;
if(k <= j)
fact = k*fact(--j);
return fact;
}
| Is This Answer Correct ? | 17 Yes | 10 No |
Post New Answer View All Answers
What is the purpose of void in c?
What is data structure in c language?
all c language question
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What is the difference between mpi and openmp?
What is the difference between a function and a method in c?
Is that possible to add pointers to each other?
What is structure in c language?
What is a method in c?
What is the difference between union and anonymous union?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What are the advantages of the functions?
Explain About fork()?
What is extern variable in c with example?