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
}