Assume that a population of green crud grows as a rate descr

Assume that a population of green crud grows as a rate described by the Fibonacci numbers and has a time period of 5 days. Hence, if a green crud population starts out as 10 pounds of crud, then after 5 days, there is still 10 pounds of crud; in 10 days, there is 20 pounds of crud; in 15 days, 30 pounds of crud; in 20 days, 50 pounds of crud, and so on, i.e., Write a program that lakes both the initial size of a green crud population (in pounds) and some number of days as input from the keyboard, and computes from that information the size of the population (in pounds) after the specified number of days. Assume that the population size is the same for four days and then increases every fifth day. The program must allow the user to repeat this calculation as long as desired. Please note that zero is a valid number of days for the crud to grow m which ease it would remain at its initial value. You should make good use of functions to make your code easy to read. Please use at least one user-defined function (except of the clear_keyboard_buffer function) to write your program. Please plan ahead and don\'t start the assignment in the last minute before the due date. You need to start it as soon as possible so you\'ll have plenty of time to study and ask questions. Technical difficulty (e.g.. internet access) is NOT an excuse that you can\'t submit the assignment on time If you can\'t immediately figure out how to write the C code, please try the following steps: think about what your program will need to do (the overall goal); list the steps (sub-tasks) that your program need to accomplish in order to achieve the overall goal, by using pseudo code (or simple English Language). I will enclose the steps at the end of this document, if you can\'t figure it out by yourself, you misread it to get more idea. I encourage you to think through by yourself first. think about what structure your code may need (e.g., if...else foe choice between conditions, loops if you need to repeatedly doing something). finally, think how you can write the code in C language. Don\'t start from this step and you may get frustrated. Your output should look something like: At the top of your program you should have a comment section that follows the below format:

Solution

#include <stdio.h>

int Fibonacci(int, int);

int main(){
   int start;
   int num_of_days;
   printf(\"Initial Size of population: \");
   scanf(\"%d\", &start);
   printf(\"\ Number of days: \");
   scanf(\"%d\", &num_of_days);
   printf(\"\ \");
   int final_population = Fibonacci(num_of_days/5 + 1, start);
   printf(\"Final Population: %d\", final_population);
}

int Fibonacci(int n, int start){
   if ( n == 0 )
      return 0;
   else if ( n == 1 )
      return start;
   else
      return (Fibonacci(n-1, start) + Fibonacci(n-2, start));
}

 Assume that a population of green crud grows as a rate described by the Fibonacci numbers and has a time period of 5 days. Hence, if a green crud population st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site