0

I'd appreciate your help as I'm stuck on the last part of Lab 1.

#include <cs50.h>
#include <stdio.h>
int main(void)
{
    // TODO: Prompt for start size
    int start;
    do
    {
        start = get_int("Start size: ");
    }
    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);
    return 0;
}

Everything is fine in the syntax until it gets to the part where it outputs the number of years it takes to get to the population. Missing "Years: " in syntax Any thoughts on what went wrong?

2 Answers 2

0

Seems to be running to completion for me. Haven't verified that the answer is correct, but that wasn't the question.

Are you sure that you saved the source code file and recompiled the program (make)?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

One problem I see is that your formatting argument of %i should be %d

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .