Write a program to compute the following
1!+2!+...n!
Answer Posted / ashish
#include<stdio.h>
int n_fact(int n);
void main()
{
int n,res;
printf("ENTER A NUMBER:-");
scanf("%d",&n);
res=n_fact(n);
printf("%d",res);
}
int n_fact(n)
{
int result;
if(n=0)
result=1;
else
result=n*n_fact(n-1);
return(result);
}
| Is This Answer Correct ? | 5 Yes | 6 No |
Post New Answer View All Answers
What are integer variable, floating-point variable and character variable?
What is the difference between %d and %i?
How to declare a variable?
How can variables be characterized?
What is c language and why we use it?
What is a structure member in c?
Which built-in library function can be used to match a patter from the string?
Is c is a high level language?
Explain how to reverse singly link list.
#include
What are volatile variables in c?
shorting algorithmS
Why main function is special give two reasons?
Write a simple code fragment that will check if a number is positive or negative.
Should a function contain a return statement if it does not return a value?