0

so I have and for loop to find the highest number in and array how would i go about outputting the element number?

//compares the values in the yearAverage array to find the highest temperature
	for(int i=0; i<lineCount; i++)
	{
		if(yearAverage[i]>=highTemp)
		{
			highTemp = yearAverage[i];
		}

	}
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by alex55
1

add another variable to keep track of the element number and use it just like you do highTemp variable that appears on line 6 of the code you posted.

0

how would i do the element number then just like

element = i

inside the if statement?

0

thanks for the help ended up being exactly what i thought thanks for pointing me in the right direction

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.