mardi 20 mars 2018

Test function for adding 2 numbers

A couple of days ago I had an interview for an internship and I've been asked to write a function that tests if another function (which was adding 2 numbers together) is working. My answer was something similar to this:

bool addTest(double a, double b){

    if((a+b) == addFunction(a, b))
        return true;
    else
        return false;
}

However, they did not seem impressed with my answer. How else could I do it?

Aucun commentaire:

Enregistrer un commentaire