Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to help with finding the bugs and the code running as it should in this assignment. Learning Outcomes Recognize common bugs, Fix common

I need to help with finding the bugs and the code running as it should in this assignment.

Learning Outcomes Recognize common bugs, Fix common bugs, Learn debugging techniques. Instructions The following program is supposed to print a list of integers and the factorial of one less than the number on the line beside it. Unfortunately, some bugs have crept into the program. You should: Run the program and see how it works, Look for bug clues that were covered in the lectures, Use whatever debugging techniques you want to find the bugs, Fix the bug(s), Repeat steps above until all bugs are fixed.

#define _CRT_SECURE_NO_WARNINGS

#include

#define MAX_FACTORIALS 10000

#define NUM_FACTS 100

struct FactorialResults

{

int results[MAX_FACTORIALS];

int numResults;

};

int factorial(const int n)

{

return (n <= n) ? n * factorial(n - 1) : 1;

}

int reduceFactorial(const int n)

{

return n / n;

}

void computeFactorials(struct FactorialResults results, int numFactorials)

{

int i;

for (i = 0; i < numFactorials; i++)

{

results.results[i] = factorial(i);

}

results.numResults = numFactorials;

}

int main(void)

{

struct FactorialResults results = { {0}, 0 };

int i;

computeFactorials(results, NUM_FACTS);

for (i = 0; i < NUM_FACTS; i++)

{

results.results[i] = reduceFactorial(results.results[i]);

printf("%5d %12f ", i, results.results[i]);

}

return 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 In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

What is the preferred personality?

Answered: 1 week ago