All might gurus of that which I don't understand-

I am a student and I am asking for some homework help (sorry, I am really stuck). I am getting a "C4430: missing type specifier - int assumed. Note: C++ does not support default-int" error, and for the life of me, I cannot figure it out. I have searched online and I am waiting for an email from my instructor, but if you guys could point me in the right direction (just explain the problem in n00b terms) I would be ever so thankful.

Ryan

int main()
{
	int HourlyTemperatures[24];
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(2);
	
	cout << "This program runs on the 24 Hour Clock. Only enter whole hours for the time." << endl;
	GetTemperatures(HourlyTemperatures);

	average = ComputeAverageTemp(HourlyTemperatures);
	cout << "Today's average temperature was: " << average << endl;

	ComputeHiLowTemp(HourlyTemperatures);
	high = HourlyTemperatures[23];
	low = HourlyTemperatures[0];
	cout << "Today's low temperature was: " << HourlyTemperatures[0] << endl;
	cout << "Today's high temperature was: " << HourlyTemperatures[23] << endl;

	return 0;
}


GetTemperatures(int HourlyTemperatures[])
{
	// Get Temps
	cout << "Hour		Temperature" << endl;
	for ( int i = 0; i < 24; i++ )
	{
		cout << i << ":00"  << "		";
		cin >> HourlyTemperatures[i];
	}

	return HourlyTemperatures[24];
}

ComputeAverageTemp(int HourlyTemperatures[])
{
	// Find Average
	int average;
	for ( int i = 0; i < 24; i++ )
	{
		average = average + HourlyTemperatures[i];
	}
	average = average/24;
	
	return average;
}


ComputeHiLowTemp(int HourlyTemperatures[])
{
	// Find High/Low
	int insert;
	for ( int i = 1; i < 24; i++ )
	{
		insert = HourlyTemperatures[i];
		int moveItem = i;
		while (( moveItem > 0 ) && ( HourlyTemperatures[moveItem - 1] > insert ))
		{
			HourlyTemperatures[moveItem] = HourlyTemperatures[ moveItem-1];
			moveItem--;
		}
		HourlyTemperatures[ moveItem ] = insert;
	}
	cout << "Today's low temperature was: " << HourlyTemperatures[0] << endl;
	cout << "Today's high temperature was: " << HourlyTemperatures[23] << endl;

	return HourlyTemperatures[0], HourlyTemperatures[23];
}

Recommended Answers

All 4 Replies

Headers are important, don't remove them. Just post actual code.

GetTemperatures(int HourlyTemperatures[])

What's the return type? And you call this function without a prototype.

sorry, the prototype is in the header file...
int GetTemperatures(int []);
int ComputeAverageTemp(int []);
int ComputeHiLowTemp(int []);

I need to pull the array (hourlytemp...) back out

>>the prototype is in the header file...

That is not enough, you cannot leave the functions' return type out of the function definitions.

Then you use the comma operator along with a return statement, that is plain wrong. Though it compiles, only the latter value is returned.

// Decide which one you want to return ...
return HourlyTemperatures[0], HourlyTemperatures[23];

thanks ya'll, my problem has been solved

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.