Write a program to compute the following
1!+2!+...n!
Answer Posted / fhghg
#include<stdio.h>
int n_fact(int n);
void main()
{
int n,res=0;
printf("ENTER A NUMBER:-");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
res+=n_fact(n);
}
printf("%d",res);
}
int n_fact(n)
{
int result;
if(n=0)
result=1;
else
result=n*n_fact(n-1);
return(result);
}
Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
Can we access the array using a pointer in c language?
Why flag is used in c?
When we use void main and int main?
What is variable and explain rules to declare variable in c?
Which header file is used for clrscr?
What is the ANSI C Standard?
How #define works?
What is the return type of sizeof?
Is c procedural or functional?
What happens if you free a pointer twice?
What is the use of #include in c?
Why is c fast?
Describe how arrays can be passed to a user defined function
Why is void main used?
program for reversing a selected line word by word when multiple lines are given without using strrev