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 |
What is a method in c?
How can I recover the file name given an open stream or file descriptor?
Explain what is the difference between declaring a variable and defining a variable?
write a program to display the numbers in the following format 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 4
What does c mean?
read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.
How to add two numbers with using function?
what is foreign key in c language?
program for following output using for loop? 1 2 3 4 5 2 3 4 5 3 4 5 4 5 5
dennis ritchie invented C language in AT&T bell laboratory what is the extension of AT&T?
What are the languages are portable and platform independent?Why they are like that?