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 |
State the difference between x3 and x[3].
Explain c preprocessor?
Why do we need a structure?
without a terminator how can we print a message in a printf () function.
How can I list all of the predefined identifiers?
what is the diff between the printf and sprintf functions?? and what is the syntax for this two functions ??
What does it mean when a pointer is used in an if statement?
Explain argument and its types.
What is meant by initialization and how we initialize a variable?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Why structure is used in c?
. A database table called PERSON contains the fields NAME, BASIC and HRA. Write a computer program to print a report which employee name and total salary for those employees whose total salary is more than 10,000. Total Salary = BASIC + HRA. At the end, the program should also print the total number of employees whose total salary is more than 10,000.