Question
Debug the following program in C: // The factorial of an integer is the product of the number with all // the positive integers below
Debug the following program in C:
// The factorial of an integer is the product of the number with all
// the positive integers below it.
// For example: Factorial of 5 = 5 * 4 * 3 * 2 * 1 = 120
#include
int factorial(int)
int main(void) {
int n,fact;
printf("Debugging Practice 1 - Quiz 3, Q3 ");
printf("Please enter the number whose factorial you wish to find: ");
scanf("%d", &fact);
fact = factorial(&fact);
printf("The factorial of %c is %f ", *fact, &fact);
}
int factorial(int number) {
if(number >= 2.0) {
return number + number-1;
} else {
return number*number + factorial(number-5.0);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started