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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!