And I know you're all excited about this as I am: I just wrote a successful script to test the user's ability to add single-digit hexadecimal numbers.
#include
#include
#include
using namespace std;
int i, r1, r2;
int sum, userInput;
int main()
{
for(i = 0; i < 16; i++)
{
srand(time(0));
r1 = (rand() % 16);
r2 = (rand() % 16);
do
{
cout << hex << r1 << endl;
cout << hex << r2 << endl;
sum = r1 + r2;
cin >> hex >> userInput;
if(userInput != sum)
cout << "TRY AGAIN\n";
}
while(userInput != sum);
cout << "good" << endl;
}
cout << "done!" << endl;
return 0;
}
ETA: Ouch! Just realized the stuff in angle brackets doesn't show up in html.
That's:
#include [iostream]
#include [ctime]
#include [cstdlib]
#include
#include
#include
using namespace std;
int i, r1, r2;
int sum, userInput;
int main()
{
for(i = 0; i < 16; i++)
{
srand(time(0));
r1 = (rand() % 16);
r2 = (rand() % 16);
do
{
cout << hex << r1 << endl;
cout << hex << r2 << endl;
sum = r1 + r2;
cin >> hex >> userInput;
if(userInput != sum)
cout << "TRY AGAIN\n";
}
while(userInput != sum);
cout << "good" << endl;
}
cout << "done!" << endl;
return 0;
}
ETA: Ouch! Just realized the stuff in angle brackets doesn't show up in html.
That's:
#include [iostream]
#include [ctime]
#include [cstdlib]