Google Answers Logo
View Question
 
Q: The Open University course T223 TMA 4 Q3 in full ( Answered 3 out of 5 stars,   0 Comments )
Question  
Subject: The Open University course T223 TMA 4 Q3 in full
Category: Computers > Programming
Asked by: reebok-ga
List Price: $20.00
Posted: 19 Sep 2002 14:58 PDT
Expires: 19 Oct 2002 14:58 PDT
Question ID: 67020
I have started, but would like it all. But is someone can help with
why I get a compiler error, Statment missing ; in fuction. On line
404. See below.
/*
 * function tms_calculate_max()
 * ============================
 * This function returns the index in TemperatureLog[]
 * of the maximum of the stored temperature readings.
 */
int tms_calculate_max(float *data, int number)
	
		{
		int i, max_index;
		float max_data;
		max_data = data[1];
		max_index = 0;
		for (i=0; i < number; i++)
			{
			If (max_data < data[i])
(line 404)			{
				max_data = data[i];
				max_index = *data[i];
				data[i]++;
				}
			}
		return (max_index);
		}

/*
 * end of tms_calculate_max()
 */
Answer  
Subject: Re: The Open University course T223 TMA 4 Q3 in full
Answered By: rbnn-ga on 19 Sep 2002 15:06 PDT
Rated:3 out of 5 stars
 
You are getting a compiler error for this program because the line:

If (max_data < data[i]) 

should read:

if (max_data < data[i]) 


 By the way, I was not quite sure if you just wanted the answer to
this one question, or if you wanted an entire course. If the latter, I
can retract this answer.

Clarification of Answer by rbnn-ga on 19 Sep 2002 16:22 PDT
I forgot to mention my search strategy; really none except writing and
debugging hundreds of thousands of lines of C in my time. When there
is a syntax error that just seems like it doesn't make any sense, it
is always a good idea to check for simple misspellings and
miscapitalizations. Some editors will highlight keywords which can
help in this situation.

Sometimes a misspelling can be so subtle it can require a long time to
really find, but it's obvious when pointed out.
reebok-ga rated this answer:3 out of 5 stars
Thank you, but yes I was hoping for the whole TMA question to be
answered,but a bit tricky to reproduce on here. You solution did work
for that problem but did through up another. Illegal use of floating
point line 406. I will try and express the question a bit further, but
there is a flow chart, which I will try and put into words. Local
variables: i  for loop counter, max_data  for the running maximum
temperature, max_data  for the array index of the running maximum
temperature, data[] for the array containig the floating point
temperatures, number for the number of readings stored in the data[]
array. Start - Set max_data to the first temperature reading - Set
max_index to zero - Set array index to zero - All readings tested? -
Yes - Return max_index - No --- Is reading > max_data ? - No -
Increment array index (return to all readings tested?) - Yes -
max_data = reading - max_index = array index of reading(which was what
I was trying to do in line 406) - Increment array index (return to all
readings tested?, in the flow chart).  I have never used google answer
before and not sure if I am compling by puting this hear any advice
welcome.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy