// Collection of code snippets by Arne VajhÃ¸j 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstdlib>

using namespace std;

int main()
{
   char cont;
   int correct = 0;
   int wrong = 0;
   do
   {
       srand(time(NULL));
       double a = rand() % 10;
       double b = rand() % 10;
       cout << a << " * X = " << b << endl;
       cout << "X = ";
       double x;
       cin >> x;
       if(fabs(x - b/a) < 0.0001)
       {
           cout << "Rigtigt" << endl;
           correct++;
       }
       else
       {
           cout << "Forkert - rigtigt er " << (b/a) << endl;
           wrong++;
       }
       cout << "Vil du prøve igen (Y/N) ? ";
       cin >> cont;
   } while((cont=='Y') || (cont=='y'));
   cout << correct << " rigtige og " << wrong << " forkerte" << endl;
   system("PAUSE");
   return 0;
}
