// 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 <cstdlib>
#include <cmath>

using namespace std;

int main()
{
    srand(time(NULL));
    while(1){
        double num1 = (rand()%21)/10.0f;
        double num2 = (rand()%21)/10.0f;
        double answer = 0;
        cout << "What is: " << num1 << " + " << num2 << " ?" << endl;
        cin >> answer;
        if(answer == num1+num2)
            cout << "correct."<<endl;
        else
            cout << "wrong. It's " << num1+num2 << " !"<<endl;
        double dif = fabs(answer - (num1+num2));
        if(dif < 0.000001)
            cout << "correct."<<endl;
        else
            cout << "wrong. It's " << num1+num2 << " !"<<endl;
    }
    return 0;
}
