34 lines
764 B
C
34 lines
764 B
C
#include <cs50.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
// TODO: Prompt for start size
|
|
int start_size = 0;
|
|
int end_size = 0;
|
|
while (start_size < 9)
|
|
{
|
|
start_size = get_int("Enter start size.\n");
|
|
}
|
|
// TODO: Prompt for end size
|
|
while (end_size < start_size)
|
|
{
|
|
end_size = get_int("Enter end size.\n");
|
|
}
|
|
// TODO: Calculate number of years until we reach threshold
|
|
int current_size = start_size;
|
|
int born = 0;
|
|
int died = 0;
|
|
int years = 0;
|
|
|
|
while (current_size < end_size)
|
|
{
|
|
born = current_size / 3;
|
|
died = current_size / 4;
|
|
current_size = current_size + born - died;
|
|
years++;
|
|
}
|
|
// TODO: Print number of years
|
|
|
|
printf("Years: %i\n", years);
|
|
} |