Files
courses/2023_CS50X/w1_c/population/population.c
T
2024-11-28 17:05:14 +01:00

38 lines
584 B
C

#include <cs50.h>
#include <stdio.h>
int main()
{
// TODO: Prompt for start size
int start;
do
{
start = get_int("Start size over 9: ");
}
while (start < 9);
// TODO: Prompt for end size
int end;
do
{
end = get_int("End size: ");
}
while (end < start);
// TODO: Calculate number of years until we reach threshold
int years = 0;
while (start < end)
{
start = start + (start / 3) - (start / 4);
years++;
}
// TODO: Print number of years
printf("Years: %i\n", years);
}