plz answer..... a program that reads non-negative integer
and computes and prints its factorial
Answer Posted / valli
//using recursion
fact(int);
main()
{
int n;
printf("enter n");
scanf("%d",n)
if(n<0)
printf("invalid number");
else
printf("factorial of %d =%d",n,fact(n));
}
fact(int n)
{
if(n==0||n==1)
return 1;
else
return n*fact(n-1);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Difference between macros and inline functions? Can a function be forced as inline?
Is it better to use malloc() or calloc()?
What are pointers? What are stacks and queues?
Can we use visual studio for c?
explain what are actual arguments?
What is omp_num_threads?
How we can insert comments in a c program?
What are the similarities between c and c++?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
What is malloc return c?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
When is the “void” keyword used in a function?
Why is c called c not d or e?
If I have a char * variable pointing to the name of a function ..
What is the time and space complexities of merge sort and when is it preferred over quick sort?