//I'm trying to write a program that uses linear search to see if an entered winning 5-digit lottery number matches the number on any of the player’s tickets(limit this number to 8 tickets).
#include <iostream>
using namespace std;
int main()
{
bool found=false;
long winticket=31419;
long ticket[8];
int index=0;
for (int i=0; i<8; i++)
{
cin>>ticket[i];
}
while (index<8 && !found)
{
if (ticket[index]==winticket)
{
found=true;
break;
}
index++;
if (found=true)
{
cout<<"Congratulations! You have the winning lottery ticket!";
else
cout<<"Sorry, you are not the holder of a winning ticket.";
}
Here's your code with indentation. As you can more easily see, your if (found=true) (which should be == BTW) are missing an }, and you main() is also missing an }.
#include <iostream>
usingnamespace std;
int main()
{
bool found=false;
long winticket=31419;
long ticket[8];
int index=0;
for (int i=0; i<8; i++)
{
cin>>ticket[i];
}
while (index<8 && !found)
{
if (ticket[index]==winticket)
{
found=true;
break;
}
index++;
if (found=true)
{
cout<<"Congratulations! You have the winning lottery ticket!";
else
cout<<"Sorry, you are not the holder of a winning ticket.";
}