Write a program to compute the following
1!+2!+...n!
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
long factorial(int,long);
void main()
{
int i,m;
long sum=0,k=1;
clrscr();
printf("enter ur no. of terms :");
scanf("%d",&m);
i=1;
while(i<=m)
{
k=factorial(i,k);
sum+=k;
i++;
}
printf("the sum is : %ld",sum);
getch();
}
int factorial(int i,long k)
{
return (i*k);
}
hope this also correct...
thank u
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Explain the difference between malloc() and calloc() function?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What is structure data type in c?
Is using exit() the same as using return?
what are the 10 different models of writing an addition program in C language?
Explain the meaning of keyword 'extern' in a function declaration.
Explain what are compound statements?
Why is c fast?
What are type modifiers in c?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is the mean of function?
What is wrong in this statement? scanf(ā%dā,whatnumber);
How are variables declared in c?
how can I convert a string to a number?
Why do we use header files in c?