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
Between macros and functions,which is better to use and why?
Why is c called a mid-level programming language?
What is the 'named constructor idiom'?
What functions are used in dynamic memory allocation in c?
define string ?
Why are algorithms important in c program?
What is the difference between array and linked list in c?
What is ambagious result in C? explain with an example.
What is strcmp in c?
Is that possible to store 32768 in an int data type variable?
What is the need of structure in c?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What are the types of assignment statements?
How many types of functions are there in c?
How arrays can be passed to a user defined function