Hello all,

I'm trying to do this homework assignment but I keep getting an error when it compiles.
The problem it has is in the startlotto function but I can't find it.
It says that I have 2 errors:

"error C2143: syntax error : missing ')' before ';'.
"error C2059: syntax error : ')'

Here is my code and thanks in advance for the help. :)

/*
    Generates five random numbers between 1 and 40 inclusive.
    Store in array.  (could be a vector)
    Sort array.
    Prompt player for 5 numbers between 1 and 40 inclusive in any order.
    Store in another array.  (could be a vector)
    If player guessed lottery numbers correctly.  Say You Win otherwise
        say You Lose and print numbers
    Allow multiple attempts.  Each attempt generates a new set of random numbers.
*/

#include <iomanip>
#include <iostream>
#include <stdlib.h>

using namespace std;

const int ARRAY_SIZE = 5;

void initializeArray(int iaList[], int listSize);
void listSort(int LSlist[], int listLength);
void startlotto(int SLList[], int size);

int main()
{
    int intList[ARRAY_SIZE];
    int i;

    char rt = 'y';

    while (rt == 'y'|| rt == 'Y')
    {
        system("CLS");

        initializeArrays(intList, ARRAY_SIZE);

        startlotto(intList, ARRAY_SIZE);

        listSort(intList, ARRAY_SIZE);

        cout << "After sorting, numbers are: " << endl;
        for (i = 0; i < ARRAY_SIZE; i++)
        cout << intList[i] << " ";

        cout << endl << endl;       //double space

        cout << "Do you want to try again? ";
        cin >> rt;
    }

}//end main

void initializeArrays(int iaList[], int listSize)
{
    int index;

    for (index = 0; index < listSize; index++)
        iaList[index] = 0;
}

void listSort(int LSlist[], int listLength)
{
    int firstOutOfOrder, location;
    int temp;

    for (firstOutOfOrder = 1; firstOutOfOrder < listLength; firstOutOfOrder++)
        if (LSlist[firstOutOfOrder] < LSlist[firstOutOfOrder -1])
        {
            temp = LSlist[firstOutOfOrder];
            location = firstOutOfOrder;

            do
            {
                LSlist[location] = LSlist[location - 1];
                location--;
            }
            while(location > 0 && LSlist[location - 1] > temp);

            LSlist[location] = temp;
        }//end if statement
}//end listSort


void startlotto(int SLList[], int size)
{
    int i, num;

    if(i = 0; i < size; i++);
    {
        //num = rand() % 40;
        SLList[i] = rand() % 40;
    }

    cout << "The integers that were entered are: " << endl;
    for (i = 0; i < size; i++)
        cout << SLList[i] << " ";

    cout << endl << endl;       //double space

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Hi JStarr :-)

Found three errors in your code:

1) In the top you declare the function initializeArray, but in the rest of the code you call it initializeArrays (Note the 's').

2) In startlotto your if-statement is supposed to be a for-statement

3) The ';' at the end of the same line is an error. Delete it.

Code for 2+3:

for(i = 0; i < size; i++) //Change 'if' to 'for' and delete ';'
{
//num = rand() % 40;
SLList[i] = rand() % 40;
}

Thank you for the help. That was it. :)

Now that you point it out it seems like easy mistakes. <sigh> Must have been tired. :P

~J

Edited 6 Years Ago by JStarr: n/a

This question has already been answered. Start a new discussion instead.