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
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What standard functions are available to manipulate strings?
What does p mean in physics?
Disadvantages of C language.
write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)
What is difference between constant pointer and constant variable?
What is 02d in c?
What are variables c?
What is a pointer in c?
What is pointer & why it is used?
What are the salient features of c languages?
In a switch statement, explain what will happen if a break statement is omitted?
How do you determine whether to use a stream function or a low-level function?
Are global variables static in c?
What are the different categories of functions in c?