In lab activity of week0 of CS50X 2021, I have found this logical error. The system is so programmed by the university to expect output 2 for the following inputs but actually, it must be 1 because after one year the llama's population becomes 1191.466663. Give it looks and tells me if it's an error or I am thinking wrong.
**
ERROR:
expected "Years: 2", not "Years: 1\n"
Log
running ./population...
sending input 1100...
sending input 1192...
checking for output "Years: 2"...
Expected Output:
Years: 2
Actual Output:
Years: 1
** Here is my complete code:
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
int start_size, end_size;
// TODO: Prompt for start size
do
{
start_size = get_int("Start size: ");
}
while (start_size < 9);
// TODO: Prompt for end size
do
{
end_size = get_int("End size: ");
}
while (end_size < start_size);
// TODO: Calculate number of years until we reach threshold
float increment = start_size;
int years = 0;
//int round_increment = round(increment);
do
{
increment = increment + increment / 12;
//increment = floor(increment + 0.5);
if (increment < end_size)
{
years ++;
}
}
while (increment < end_size);
// TODO: Print number of years
printf("Years: %i\n", years);
}