# Can't seem to get total number of years to print properly in Lab 1

I'm new to coding and I've been having trouble with Lab 1. I was able to get the program to properly ask for a start and end size, but the number of years is not listed.

Here's an example:

``````population/ \$ make population
population/ \$ ./population
Start Size 9
End Size 10
``````

And other times, I get multiple outputs of years, such as:

``````population/ \$ make population
population/ \$ ./population
Start Size 9
End Size 19
Years: 9  Years: 10  Years: 11  Years: 12  Years: 13  Years: 14  Years: 15  Years: 16  Years: 17
``````

I think I'm getting confused on how to run the loop so that the start size reaches the end size, while also keeping a counter of the number of years it takes.

Here's the code that I have so far:

``````#include <cs50.h>
#include <stdio.h>
#include <math.h>

int main(void)
{
// TODO: Prompt for start size
int s;

do
{

s = get_int ( " Start Size " );
}

while ( s < 9 || s % 1 != 0 ); // No less than 9 and no decimals

// TODO: Prompt for end size
int e;

do // Makes sure minimum is smaller than maximum

{
e = get_int ( " End Size " );
}

while ( e < s || e % 1 != 0 ); // last part is for no decimals

if ( s == e ) // If start and end are the same

{ printf ( " Years: 0 " ) ;}

// TODO: Calculate number of years until we reach threshold

int n;

int y;

for ( n = s ; n + ( trunc ( n / 3 ) - trunc ( n / 4 ) ) < e ; n++ )

{
// TODO: Print number of years

printf ( " Years: %i " , n );

}

}

``````