Question: Hi I need some help modifying my code for my assignment, this is the assignment: And here is my code in C: #include #include void
Hi I need some help modifying my code for my assignment, this is the assignment: 
And here is my code in C:
#include
#include
void clearKeyboardBuffer();
int main()
{
char ans = 'y';
//program wants the user to be trapped in a loop so I need a while statement
while(ans == 'y')
{
int a;
int c;
int d;
int counter = 0;
int count = 0;
do
{
printf("Please enter the initial value of the green crud: ");
scanf("%d", &a);
clearKeyboardBuffer();
if (a 100)
{
printf("I'm sorry that value is either unrecognized or negative ");
counter++;
}
}
while(a 100);
{
printf("Please enter the number of days passed by: ");
scanf("%d", &d);
int n = d / 5, first = a, second = a, next;
for(c = 0; c
{
next = first + second;
first = second;
second = next;
}
if(d >= 0 && d
{
printf("With the initial population of %d pounds of crud growing for %d days ", a, d);
printf("The final population would be %d pounds ", a);
}
else
{
printf("With the initial population of %d pounds of crud growing for %d days ", a, d);
printf("The final population would be %d pounds ", next);
}
do
{
printf("Would you like to continue? (y): ");
scanf(" %c", &ans);
if(ans != 'y' || ans != 'n')
{
printf("I'm sorry that answer is not recognized ");
count++;
}
}
while(ans != 'y' || ans != 'n');
}
return 0;
}
}
void clearKeyboardBuffer()
{
char ch;
scanf("%c", &ch);
while(ch != ' ')
{
scanf("%c", &ch);
}
}
I'm having trouble with looping once the user has inputted their numbers and received an answer.
Any help/tips/advice on this would be very helpful, thank you so much!
th The n" Fibonacci number F is defined as follows: an In other words, each number is the sum of the two previous numbers in the sequence. Thus, the first several Fibonacci numbers are 1, 1, 2, 3, 5, and 8. Interestingly, certain population growth rates are characterized by the Fibonacci numbers. If a population has no deaths, then the series gives the size of the population after each time period. Assume that a population of green crud grows at 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 1:5 days, 30 pounds of crud; in 20 days, 50 pounds of crud, and so on, i.e., 10 20 25 80 Davs 20 50 30 Crud (pounds) 10 10 30 Write a program that takes 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 in which case 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
