Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

LO5 Illustrate the steps in developing a base pay system.

Answered: 1 week ago