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 good way to implement complex numbers in c?
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.
Explain threaded binary trees?
What are the application of c?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
#include
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
what is the different bitween abap and abap-hr?
Are comments included during the compilation stage and placed in the EXE file as well?
how many errors in c explain deply
What are reserved words?
What is the explanation for prototype function in c?
How do I copy files?
Why is it that not all header files are declared in every C program?