This code generates 5 random numbers from 1-6. It then stores the numbers into an array that holds 5 numbers. After that, it then prompts the user to enter those five numbers. How do I check if 'cin' matches the numbers in the array?
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>
using namespace std;
int magicNumbers;
int code;
int array[5];
void enterCode()
{
cout << "\n\n\n\nEnter your given code: ";
cin >> code;
if(code == array[])
{
cout << "Yes!";
}
else if(code != array[])
{
cout << "No!";
}
}
int main()
{
srand(time(NULL));
for(int x = 0; x < 5; x++)
{
magicNumbers = 1+rand()%6;
array[x] = magicNumbers;
cout << magicNumbers << endl;
}
cout << "\nThe Array" << endl;
cout << "-----------------" << endl;
cout << array[0] << array[1] << array[2] << array[3] << array[4];
Sleep(2000);
enterCode();
return 0;
}