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


Please Help Members By Posting Answers For Below Questions

Explain what are header files and explain what are its uses in c programming?

624


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1576


What's the best way of making my program efficient?

622


What is a macro in c preprocessor?

625


write a program to print largest number of each row of a 2D array

1868






What's the difference between constant char *p and char * constant p?

652


What are the advantages of the functions?

602


How can I implement sets or arrays of bits?

602


int i=10; printf("%d %d %d", i, i=20, i);

1009


What are the types of c language?

552


What are the types of pointers?

597


What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }

695


List the difference between a "copy constructor" and a "assignment operator"?

579


How can I trap or ignore keyboard interrupts like control-c?

619


Write a function that will take in a phone number and output all possible alphabetical combinations

595