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
Explain how can you be sure that a program follows the ansi c standard?
What is #define in c?
Can you mix old-style and new-style function syntax?
What are run-time errors?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Is c procedural or functional?
When can you use a pointer with a function?
What is break statement?
What is call by value in c?
Can a program have two main functions?
What is the advantage of using #define to declare a constant?
Tell me about low level programming languages.
What are enumerated types?
Can the curly brackets { } be used to enclose a single line of code?
Write a program to swap two numbers without using third variable?