Advertisement

Simple Code Problem

Started by May 16, 2001 04:39 PM
4 comments, last by Squeejee 23 years, 8 months ago
I have problems compiling because of lines 28, 37, 51, and 54. Can anyone help?
          
#include <iostream>

#include <string>

#define TIMES_DAILY 3

#define MAX_DAYS 5


int i=0;
int day=0;


void main()
{


float humidity[5][3] = {0};
float input=0;
float average=0;
string num[] = { "first", "second", "third", "fourth", "fifth" };
string time[] = { "morning", "midday", "evening" };


//get readings

while(day < MAX_DAYS)
{


 while(i < TIMES_DAILY)
 {
  cout << "Input the humidity read in the " << time[i] << " on the "
       << day[num] << " day: ";
  cin >> input;
  cout << "\n";
  humidity[day][i] = {input};   ///////////////////////////////line 28

  i++;
 }


 day++;
 i = 0;
}


//find average readings



while(day < MAX_DAYS)   //////////////////////////////////////////line 37

{


 while(i < TIMES_DAILY)
 {
 average += humidity[day][i];
  ::i++;
 }


::day++;
::i = 0;
}


//output average humidity

cout << "\n\n" << "The week's average humidity was: " << ::average;  /////////////////line 52 



char getchar();
}   ///////////////////////////////////////////////////////////line 54

          
----------------------- Hail to the king, baby. Edited by - Squeejee on May 16, 2001 6:35:51 PM
-----
No ... we can''t help you

POST THE EXACT ERROR MESSAGE!

When you seperate out just a piece of a program ... it is IMPOSIBLE to know what the cause of an UNKNOWN error is. Example ... do you have a using namespace std; line in your code? If not, then the cout in line 52 would be invalid ... etc etc ... post the WHOLE program AND the error messages if possible ... if not at least post the error messages.
Advertisement
Line 28: parse error before `{'
Line 37: parse error before `while'
Line 51: syntax error before `<'
Line 54: parse error before `}'

And that IS the whole program.

Edited by - Squeejee on May 16, 2001 6:29:27 PM
-----
curly braces around input on line 28 shouldn''t be there

DSutherland
Thanks DSutherland! That was the source of all my problems.
-----
Why are you putting :: infront of all of those variables? It isn''t needed. Also, instead of "char getchar();" write "getchar();". And DSutherland is correct about the braces.

Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/

This topic is closed to new replies.

Advertisement