I have this string function that should calculate the average of and array compare the values of the 12 numbers and output which month has the highest temperature
-(0-11) = (Jan-Dec)
-all variables not defined in the function are defined globally

The problem is when I compile and run the program it outputs nothing the rest of the program runs well it is just this one function I'm having issues with.

Thanks in advance for any help or ideas

//returns the month name of the highest averaged month
string monthName()
{
	int highest=0;
	string monthN;
	for(int i=0; i<month; i++)
	{
		for(int j=0; j<numRecords; j++)
		{
			summedMonths[i]=monthArray[i][j]+summedMonths[i];
		}
	}

	for(int i=0; i<month; i++)
	{
		averaged[i]=summedMonths[i]/month;
	}

	for(int i=0; i<month; i++)
	{
		averaged[i];
		if(i>highest)
		{
			highest=i;
		}
	}
	if(highest == 0)
		monthN = "January";
	if(highest == 1)
		monthN = "February";
	if(highest == 2)
		monthN = "March";
	if(highest == 3)
		monthN = "April";
	if(highest == 4)
		monthN = "May";
	if(highest == 5)
		monthN = "June";
	if(highest == 6)
		monthN = "July";
	if(highest == 7)
		monthN = "August";
	if(highest == 8)
		monthN = "September";
	if(highest == 9)
		monthN = "October";
	if(highest == 10)
		monthN = "November";
	if(highest == 11)
		monthN == "Decemeber";
	return monthN;
}
averaged[i];
if(i>highest)

You probably want

if( averaged[i] > averaged[highest] ){ highest = i; }

That worked thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.