c program to manipulate x=1!+2!+3!+...+n! using recursion



c program to manipulate x=1!+2!+3!+...+n! using recursion..

Answer / satya

#include<stdio.h>
#include<conio.h>
int sumfact(int n)
{ int cnt=0,out;
if(cnt==0)
out=1;
if(n==1)
return out;
else
{
int i,fact=1;
for(i=n;i>=2;i--)

fact*=i;
out+=fact;
cnt++;

return out+sumfact(n-1);
}
}
main()
{
int out,n;
clrscr();
printf("Enter the vlue of n ");
scanf("%d",&n);
out=sumfact(n);
printf("%d",out);
getch();
}

Is This Answer Correct ?    6 Yes 6 No

Post New Answer

More C Interview Questions

why we use "include" word before calling the header file. is there any special name for that include??????

1 Answers   TCS,


What is sizeof return in c?

0 Answers  


#include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain &#1567;&#1567;&#1567;

4 Answers  


how to print 2-D array using a single for loop?

2 Answers   Mind Tree, TCS, Value Labs,


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

0 Answers  


to find the closest pair

0 Answers   Infosys,


What are different storage class specifiers in c?

0 Answers  


will u please send me the placement papers to my mail???????????????????

0 Answers  


Explain #pragma in C.

1 Answers  


an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

0 Answers  


What is the difference between null pointer and the void pointer?

3 Answers  


Is reference used in C?

1 Answers  


Categories