hi guys.
i've been making a simple (or so i thought) memory test game on c++ to help me learn. ive encountered a number of problems that were eventualy solvable and ive been at this one for hours:
in the phase of the user typing back the numbers no matter what you write it comes up as correct. im probably just being stupid but i cant work out how to make it come up as incorrect when the user puts an incorrect value.Code:#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <stdlib.h>
using namespace std;
int main()
{
int numberarray[20];
int numberarrayplace;
int numberrecal;
int numberrecalamount;
int exitcheckloop;
cout<<"Welcome to Dave's memory lab! \n";
cout<<"Here we will carry out a test: \n";
cout<<"Remember the numbers! \n";;
cout<<"you have 30 seconds to memorize them \n";
cout<<"Then you will be tested \n";
cout<<"Press enter to continue... \n";
cin.get();
Sleep(1000);
cout<<"3 \n";
Sleep(1000);
cout<<"2 \n";
Sleep(1000);
cout<<"1 \n";
Sleep(1000);
system("cls");
cout<<"Here are your numbers \n";
numberarrayplace = 1;
do {
numberarray[numberarrayplace] = rand() % 99 + 1;
cout<< numberarray[numberarrayplace] << " \n";
numberarrayplace = numberarrayplace + 1;
} while ( numberarrayplace < 21 );
Sleep(30000);
system("cls");
cout<<"Times up! \n";
cout<<"Now you must type the numbers back in! \n";
numberarrayplace = 0;
numberrecalamount = 1;
do {
cin>> numberrecal;
exitcheckloop = 0;
do {
if ( numberarrayplace > 20 ) {
cout<<"Incorrect! \n";
numberrecalamount = numberrecalamount + 1;
numberarrayplace = 0;
exitcheckloop = 1;
}
else if ( numberarray[numberarrayplace] = numberrecal) {
cout<<"Correct! \n";
numberarrayplace = 0;
numberrecalamount = numberrecalamount + 1;
exitcheckloop = 1;
}
else {
numberarrayplace = numberarrayplace + 1;
}
} while ( exitcheckloop = 0 );
} while ( numberrecalamount < 21 );
}
can anyone help me !?!?!
thanks
gillypie