So i got a question where i need to display the year where the minimum is found and its number. i got the result to post but it loops. how do i set it up so it only displays the year and the data from the array it represents?
float LAN(void)
{
int min;
min = Y2012[1];
printf("The Minimum is %d\n and the minimum year is 2012\n", min);
if (Y2013[1] < min)
{
min = Y2013[1];
printf("The Minimum is %d\n and the minimum year is 2013\n", min);
}
if (Y2014[1] < min)
{
min = Y2014[1];
printf("The Minimum is %d\n and the minimum year is 2014\n", min);
}
if (Y2015[1] < min)
{
min = Y2015[1];
printf("The Minimum is %d\n and the minimum year is 2015\n", min);
}
if (Y2016[1] < min)
{
min = Y2016[1];
printf("The Minimum is %d\n and the minimum year is 2016\n", min);
}
}
I see no "loop" in your code. Not much or arrays either, but lets ignore that.
1 2 3 4 5 6
int min;
int year;
// set those values
printf("The Minimum is %d\n and the minimum year is %d\n", min, year );
In other words, you cannot print anything before you do know the result. In your code you don't know it until after line 26. Since you can store the "least value found so far", you can surely store "year of that least value so far".