C Programming. Spread code across multiple files. Create Fibonacci function. Store in array.
Do not edit main.c in this lab assignment! However, notice that the function compute_fibs() is not defined.
Instead of adding the definition of compute_fibs() directly to main.c, your job is to create two additional files and add them to your project:
- mymath.h -- This file should contain the function declaration for the compute_fibs() function you are going to define in mymath.c
- mymath.c -- This file will contain the function compute_fibs() that computes the 1st N elements of the Fibonacci sequence. These N elements will be stored sequentially into the array fibs that was passed into the function by reference. The declaration of this function looks like this:
void compute_fibs (unsigned long int *fibs, unsigned int *N);
Your compute_fibs() function should be smart enough to return early if the numbers in the Fibonacci sequence become too large to be stored into an unsigned long int. If this happens, update the data referenced by the variable N that was passed into the function to contain the number of elements in the Fibonacci sequence you actually computed before being forced to return early.
- Use the macro ULONG_MAX defiend in limits.h. You will need to do a little math to check the inequality properly (i.e. foo > ULONG_MAX won't work since foo can't store values bigger than ULONG_MAX if foo is an unsigned long!)
#define ELEMENTS 100
int main ()
unsigned int i;
unsigned long int fibs[ELEMENTS];
unsigned int n = ELEMENTS;
compute_fibs (fibs, &n);
for (i=0; i printf ("fibs[%i]: %lu\n", i, fibs[i]);
printf ("Displaying %u fibs\n", n);
Get Help With a similar task to - C Programming. Spread code across multiple files. Create Fibonacci function. Store in array.
Tutlance Experts offer help in a wide range of topics. Here are some of our top services:
- Math homework help
- Nursing homework help
- Statistics homework help
- Nursing coursework help
- Capstone project writing services
- Essay writers for hire
- Case study writing help
- Buy college papers online
- Buy college research papers
- College homework help
- Professional resume writing services
- Programming homework help
- Coursework writing help
- Term paper writing help
- Biology homework help
- Do my physics homework
- Dissertation data analysis help
- PhD Dissertation writing services
- Chemistry homework help
Post your project now for free and watch professional experts outbid each other in just a few minutes.