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


Please Help Members By Posting Answers For Below Questions

Can we access the array using a pointer in c language?

558


Why flag is used in c?

651


When we use void main and int main?

588


What is variable and explain rules to declare variable in c?

550


Which header file is used for clrscr?

575






What is the ANSI C Standard?

775


How #define works?

613


What is the return type of sizeof?

588


Is c procedural or functional?

582


What happens if you free a pointer twice?

607


What is the use of #include in c?

571


Why is c fast?

601


Describe how arrays can be passed to a user defined function

777


Why is void main used?

614


program for reversing a selected line word by word when multiple lines are given without using strrev

1942