Thread: Arrays~

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12

    Arrays~


    //Sam Huang
    //Cs 209-2393
    //Arrays
    //Prof. Borda
    //Sept. 18,2003

    #include <iostream>
    using namespace std;
    const int max=50;
    void main();
    {
    int a[max];bool ok;
    int n; float avg;
    int n=22;
    getdata (a[], n);
    output (a[],n);
    reverse (a[],n);
    average (a[], n);
    avg=average (a[], n);
    cout<<"average"<<avg;
    item=100;
    ok=linearserach(a[]n, item);
    if (ok) cout<<"yes":
    else
    cout<<"no";
    return;
    }

    void reverse (int r[], int nn);
    {
    int i;
    for (i=(n-1); i>=0;i--)
    {
    cout<<r[i]<<"";
    float average (int r[]; int n)
    {
    int i; int sum;//sum=0
    for (i=0; sum=0;i<<nn;i++)
    {
    sum=sum+r[i]
    }
    float temp sum;// floattemp= float (sum);
    return (temp/nn);

    sort (a].n);
    void sort (int r[] int nn)
    {
    int [i]
    for (j=0;j<(nn-1);j++)
    if (r[j+1]j<r[j]
    {
    int T=r[j];
    r[j]=r[j+1];
    r[j+1]=t;
    }
    }//for j
    }//for i
    }//sort


    }

    got 2 errors..~


    (11) : error C2447: missing function header (old-style formal list?)
    (30) : error C2447: missing function header (old-style formal list?)
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,117
    Rep Power
    1803
    Remove the semicolons from the ends of the function headers (lines 10 and 29). They should not be there, you only do that in forward declarations (like in header files), not in the actual definition.

    Clifford
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    12
    But when i remove it, i get like 22 erros...blah.!!
  6. #4
  7. No Profile Picture
    status unknown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    262
    Rep Power
    12
    It doesn't necessarily mean you have 22 things wrong with your code. One single problem with your code can cause multiple compilation errors. Just work your way through the list of errors.

    Note that you're calling functions inside main() that haven't been declared. If you add function prototypes to your program before main() it should help.

IMN logo majestic logo threadwatch logo seochat tools logo