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 is a pointer and how it is initialized?
How to declare pointer variables?
What is echo in c programming?
What's the total generic pointer type?
Is the exit() function same as the return statement? Explain.
What is the best way to comment out a section of code that contains comments?
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?
What is a spanning Tree?
What is string in c language?
write a program in c language to print your bio-data on the screen by using functions.
What is calloc()?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is getch() function?
What are structures and unions? State differencves between them.
why return type of main is not necessary in linux