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


Please Help Members By Posting Answers For Below Questions

Explain the difference between malloc() and calloc() function?

597


What does the message "automatic aggregate intialization is an ansi feature" mean?

691


What is structure data type in c?

567


Is using exit() the same as using return?

672


what are the 10 different models of writing an addition program in C language?

1435






Explain the meaning of keyword 'extern' in a function declaration.

718


Explain what are compound statements?

603


Why is c fast?

601


What are type modifiers in c?

620


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

613


What is the mean of function?

644


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

723


How are variables declared in c?

597


how can I convert a string to a number?

594


Why do we use header files in c?

574