HEy guys a lil help.

So this for a class asignment.
Creating a linear search.
This ia what i have but its giving me syntax errors when i try to complie to test.
any pointers as to what i did wrong ?

kept getting errors for the 'size' and playerNumber' located in the search function
===========================================


//Linear search program to find wining lotto number

//header
#include <iostream>
using namespace std;

//size definition
#define size 10

bool findWinner(int [],int ,int);

//main function
int main()
{
//start array with known numbers
int winningNumbers[10]=
{13579,
26791,
26792,
33445,
55555,
62483,
77777,
79422,
85647,
93121};

//finding player number and entering
int playerNumber;
cout<<"Please Enter your Lotto Numbers: ";
cin>>playerNumber;

//search function and storing return value to result
bool result= findWinner(winningNumbers,size,playerNumber);

//verification
if(result)
cout<<"Congradulations You have one of the winning numbers!!!"<<endl;
else
cout<<"Sorry, but you do not have a winning number."<<endl;
system("pause");
}
//End of main function

//search function

bool findWinner(int winningNumbers[],int size,int playerNumber)
{
//Expressing bool and set value to false
bool found = false;

//expressing index and setting to 0
int index = 0;

//loop until is found or to the size of array
while(index<size&!found)
{
//comparing array and player entry
if(winningNumbers[index]==playerNumber)
found = true;
index++;
}
return found;
}
//end of function
Change

#define size 10


to

const int size = 10;
ty vlad that worked perfectly
Topic archived. No new replies allowed.