c program to manipulate x=1!+2!+3!+...+n! using recursion
Answer Posted / 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 View All Answers
What are pointers really good for, anyway?
When should I declare a function?
How many identifiers are there in c?
What is hungarian notation? Is it worthwhile?
Do you know the purpose of 'register' keyword?
please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics
What are lookup tables in c?
What is the use of a static variable in c?
What is console in c language?
Write a program to check palindrome number in c programming?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
Difference between goto, long jmp() and setjmp()?
What does %p mean c?
Why we use void main in c?
Explain data types & how many data types supported by c?