One program using three functions to compare two double-precision numbers I am currently learning C++ though Bjarne Stroustrup book Programming Principles and Practices using C++.

Going through the drills, I am trying to purposefully write efficient and readable code (good coding practices. However, I think I may be overdoing it with my use of functions for tasks within my program.

//Function to check if the entered numbers are similar in value
double similarValues(double valueBigger, double valueSmaller)
{
    if ((valueBigger - valueSmaller) &lt; 0.01) {
        return 1;   //Return 1 if the values are similar
    }
    else {
        return 0;
    }
}

//Function checks which value is larger
double valueLarger(double value01, double value02)
{
    if (value01 &gt; value02) {
        return value01;
    }
    else if (value01 &lt; value02) {
        return value02;
    }
    else {
        return 0;       //Return 0 if the values are equal!
    }
}

//Function checks which value is smaller
double valueSmaller(double value01, double value02)
{
    if (value01 &gt; value02) {
        return value02;
    }
    else if (value01 &lt; value02) {
        return value01;
    }
    else {
        return 0;       //Return 0 if the values are equal!
    }
}

int main()
{

    // Reads two integers on each loop and prints them//
    double value02; 
    double value01;

    while (cin &gt;&gt; value01 &gt;&gt; value02) {

        // Checks if the functions valueSmaller &amp; valueLarger have not retuned 0
        if (valueSmaller(value01, value02) != 0 || valueLarger(value01, value02) != 0) {
            cout &lt;&lt; "The smaller value is: " &lt;&lt; valueSmaller(value01, value02) &lt;&lt; " , the larger value is: " &lt;&lt; valueLarger(value01, value02) &lt;&lt; "\n";

            //Checks if the values are at least similar, returns 1 if true
            if (similarValues(valueLarger(value01, value02), valueSmaller(value01, value02)) == 1) {
                cout&lt;&lt;"The numbers are almost equal. \n";
            }
        }
        // If functions valueSmaller &amp; valueLarger have returned 0 then do the below instuction
        else if (value01 == value02) {
            cout &lt;&lt; "Both of these numbers are equal!" &lt;&lt; "\n";
        }
        // If the values entered cannot be processed then output an error message
        else {
            cout &lt;&lt; "Not a value I know! Incorrect input" &lt;&lt; "\n";
        }

    }
}


Please critically (I do not mind if it is harsh) state what programming practices I am not following or following correctly. Also, whether my coding is on par with what you would deem as following great coding conventions.


Am I overdoing the functions?
Am I using return values differently then they should be used?
Is my code readable?
Are my comments accurate and to the point or are they vague?
Your functions and their use are very curious:


A function to determine if two values are similar should be symmetric in its arguments, and return a bool.
A function determining the truth of a property should be called is@. similarValue is a bit of a puzzler, which is actually good as the functions behavior is very surprising.
A conditional expression returns a bool, which can be implicitly converted to an integer of value 0 (false) or 1 (true).
I'm not sure what I should do with valueSmaller and valueLarger, but I am sure that I don't want to see anything like them ever again.


Other points:


Seems you also don't know the conditional-operator (expr ? value-if-true : value-if-false). It can be used to write things better, but beware of getting carried away with it.
You are using using namespace std;.
That's a bad idea, read "Why is “using namespace std;” considered bad practice?".
When you output string- and char-literals consecutively, just concatenate them together. Also, if you have a length-1-string-literal, a char-literal can serve the same purpose more efficiently.
Your comments are, I'm sorry to say, useless, as they just rephrase some of the more obvious code.
When you use descriptive names, most other comments for describing what code does also become superfluous (exception: doc-comments which will be extracted for bare-bones documentation).
Comments are for giving non-obvious reasons for doing things you do, reasons for doing them the way you do them, or describing how you do something.
See this good answer by rolfl about how to properly comment.