write a program that finds the factorial of a number using
recursion?
Answer Posted / sibnath halder
//*write a c program to calculate factorial by using
recursion*//
#include<stdio.h>
void main()
{
int factorial(int);
int n;
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}
| Is This Answer Correct ? | 10 Yes | 5 No |
Post New Answer View All Answers
Why should I use standard library functions instead of writing my own?
Does c have enums?
Explain what is the difference between a string and an array?
How can I discover how many arguments a function was actually called with?
Can the curly brackets { } be used to enclose a single line of code?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
how do you execute a c program in unix.
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What is difference between function overloading and operator overloading?
What is an array? What the different types of arrays in c?
How do I use strcmp?
Explain how do you view the path?
Is it cc or c in a letter?
Why static is used in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.