Need help with code only one error left!!!

it compiles but closes my program and i am able to do nothing please help!!!





#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>

using namespace std;

int main()
{

int lottery [4], user [4];
int count=0;

for (int i=0; i<4; i++)

{
lottery [i]= 1 + rand () %9;
}

cout << "Enter four numbes: \n";


for(int i=0; i<4; i++)

cin >> user [i];

cout << " ThE luCkY NuMbErS ArE: \n";

for (int i=0; i,4; i++)

{

if( lottery [i]==user[i])

{

cout << lottery [i] << " ";

count ++;

}

}

if (count==4)

cout << " Winner!!!! of the $10000 TaX FrEe.";

cin.ignore (1000, '\n');
cin.get();

return 0;

}
You count is most likely not reaching the needed value of 4 because count only increments if the value stored in the lottery array are the same as that stored in the user array. While possible it is unlikely that random integers selected 1 - 9 would be chosen exactly matching that of what the user gave.

Either keep asking for numbers until the arrays match or more probable have an else statement on the last if to say they did not win the lottery.
Topic archived. No new replies allowed.