7. (A) Write a program to find the factorial of a number using recursive function.

7. (A) Write a program to find the factorial of a number using recursive function.
Write a program to find the factorial of a number using recursive function.


#include <stdio.h>
long int multiplyNumbers(int n);
int main()
{
int n;
printf("Enter a positive integer: ");
scanf("%d", &n);
printf("Factorial of %d = %ld", n, multiplyNumbers(n));
return 0;
}
long int multiplyNumbers(int n)
{
if (n >= 1)
return n*multiplyNumbers(n-1);
else
return 1;
}
7. (A) Write a program to find the factorial of a number using recursive function. 7. (A) Write a program to find the factorial of a number using recursive function. Reviewed by admin on December 23, 2019 Rating: 5

No comments:

Powered by Blogger.