Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-18-2006, 01:33 AM   #1 (permalink)
joelw
Code Monkey
 
Join Date: Sep 2006
Posts: 36
joelw is on a distinguished road
help with arrays

Ok, i have program written to find the total amount of rainfall, the average , the highsest and lowest. Now i am compiling it and im getting a expected unqualified-id before token '{' token error message? can anyone look at my code and see why im getting this error its probably really simple but i can see it.
Thanks in advance.

Code:
#include <iostream>
#include <iomanip>

using namespace std;

// Function prototypes
double sumArray(double[], int);
double getHighest(double[], int);
double getLowest(double[], int);

int main()
{
    const int MONTHS = 12;
    double amount[MONTHS],           // To hold the amount of rainfall
           total,                    // To hold the total rainfall
           average,                  // To hold the average rainfall
           highest,                  // To hold the highest rainfall amount
           lowest;                   // To hold the lowest rainfall amount
    
    cout << "Enter the rainfall for each month.\n";
    for (int count = 0; count < MONTHS; count++)
    {
        cout << "Month " << (count + 1) << ": ";
        cin >> amount[count];
    }
    
    // Get the total monthly rainfall
    total = sumArray(amount, MONTHS);
    
    // Calculate the average rainfall
    average = total / MONTHS;
    
    // Find the highest monthly rainfall
    highest = getHighest(amount, MONTHS);
    
    // Find the lowest monthly rainfall
    lowest = getLowest(amount, MONTHS);
    
    // Display the results
    cout << fixed << showpoint << setprecision(2);
    cout << "The total monthly rainfall is" << total << endl;
    cout << "The average monthly rainfall is" << average << endl;
    cout << "The highest montthly rainfall is" << highest << endl;
    cout << "The lowest monthly rainfall is" << lowest << endl;
           
    system("PAUSE");
    return EXIT_SUCCESS;
}

//******************************************************************
// Definition of sumArray                                          *
// This function accepts a double array and its size               *
// as arguments. The sum of the array's elements                   *
// is returned as an double.                                       *
//******************************************************************

double sumArray(double array[], int size)
{
       double total = 0;
       
       for (int count = 0; count < size; count++)
           total += array[count];
       return total;
}

//******************************************************************
// Definition of getHighest                                        *
// This function accepts a double array and its size               *
// as arguments. The highest value in the array is                 *
// returned as an double.                                          *
//******************************************************************

double getHightest(double array[], int size)
{
       double highest;
       
       highest = array[0];
       for (int count = 1; count < size; count++)
       {
           if (array[count] > highest)
              highest = array[count];
       }
       return highest;
}

//*******************************************************************
// Definition of getLowest                                          *
// This function accepts a double array and its size                *
// as arguments. The lowest value in the array is                   *
// returned as an double                                            *
//*******************************************************************

double getLowest(double array[], int size);
{
       double lowest;
       
       lowest = array[0];
       for (int count = 1; count < size; count++)
       {
           if (array[count] < lowest)
              lowest = array[count];
       }
       return lowest;
}
joelw is offline   Reply With Quote
Old 10-18-2006, 03:19 AM   #2 (permalink)
Bhruic
Registered User
 
Join Date: Sep 2006
Posts: 5
Bhruic is on a distinguished road
Code:
double getLowest(double array[], int size);
{
       double lowest;
       
       lowest = array[0];
       for (int count = 1; count < size; count++)
       {
           if (array[count] < lowest)
              lowest = array[count];
       }
       return lowest;
}
It's right there. More specifically, the first line, where you have a ';' on the end that shouldn't be there.

Bh
Bhruic is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File I/O and arrays JaySun Standard C, C++ 6 03-24-2005 10:43 PM
combining arrays Engineer Standard C, C++ 11 03-12-2005 10:23 AM
Dynamic Arrays, the 'right' way. Mr.Anderson Standard C, C++ 10 10-05-2004 06:00 AM
need help with arrays CoW Standard C, C++ 12 11-04-2003 10:09 AM


All times are GMT -8. The time now is 04:48 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting