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
Define Array of pointers.
How can you tell whether two strings are the same?
Write a program that accept anumber in words
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
i got 75% in all semester am i eligible for your company
What is the difference between far and near in c?
What is typedef struct in c?
How can I change the size of the dynamically allocated array?
Can true be a variable name in c?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is the difference between a function and a method in c?
What is the advantage of an array over individual variables?
What is indirection? How many levels of pointers can you have?
What is the difference between fread and fwrite function?
Why we write conio h in c?