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


Please Help Members By Posting Answers For Below Questions

What is a pointer and how it is initialized?

611


How to declare pointer variables?

688


What is echo in c programming?

561


What's the total generic pointer type?

618


Is the exit() function same as the return statement? Explain.

667






What is the best way to comment out a section of code that contains comments?

786


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

983


What is a spanning Tree?

959


What is string in c language?

630


write a program in c language to print your bio-data on the screen by using functions.

6253


What is calloc()?

631


what do u mean by Direct access files? then can u explain about Direct Access Files?

1644


What is getch() function?

651


What are structures and unions? State differencves between them.

619


why return type of main is not necessary in linux

1708