Right triangle side length calculation My code compiles and executes.  I would like to hear any comments or suggestions pertaining to my use of C++.

#include &lt;iostream&gt;
#include &lt;math.h&gt;

bool error_check(){
    if(!std::cin){
        std::cin.clear();
        std::cin.ignore(256,'\n');
        return true;        
    }
    else 
        return false;
};

int main(){

//This line outputs directions for the user to follow.
std::cout &lt;&lt; "\nEnter real numbers for side lengths.\n" &lt;&lt;
                 "\nEnter zero for an unknown side length.\n" &lt;&lt; 
                 "\nTo exit enter zero for all side lengths.\n" &lt;&lt; std::endl;

while(true){

    //This line prompts the user to enter a side length.
    std::cout &lt;&lt; "side a: "; 
    //This line initializes and stores user input into a variable for calculation.
    float sidea = 1; std::cin &gt;&gt; sidea;
    //This condtional branch handles bad user input which is in this case anything but real numbers.
    if(error_check()){
        std::cout &lt;&lt; "\nYou must enter a real number.\n" &lt;&lt; std::endl;      
        continue;
    }

    //This line prompts the user to enter another side length.
    std::cout &lt;&lt; "side b: ";
    //This line initializes and stores user input into a variable for calculation.
    float sideb = 1; std::cin &gt;&gt; sideb;
    //This condtional branch handles bad user input which is in this case anything but real numbers.
    if(error_check()){
        std::cout &lt;&lt; "\nYou must enter a real number.\n" &lt;&lt; std::endl;      
        continue;
    }

    //This line prompts the user to enter a final side length.
    std::cout &lt;&lt; "side c: ";
    //This line initializes and stores user input into a variable for calculation.
    float sidec = 1; std::cin &gt;&gt; sidec; 
    //This condtional branch handles bad user input which is in this case anything but real numbers.
    if(error_check()){
        std::cout &lt;&lt; "\nYou must enter a real number.\n" &lt;&lt; std::endl;      
        continue;
    }

    //This conditional branch calculates and outputs the unknown side length.
    if(sidea == 0){
        sidea = sqrt(pow(sidec,2) - pow(sideb,2));
        std::cout &lt;&lt; "side a= " &lt;&lt; sidea &lt;&lt; "\n" &lt;&lt; std::endl;
    }
    else if(sideb == 0){
        sideb = sqrt(pow(sidec,2) - pow(sidea,2));
        std::cout &lt;&lt; "side b= " &lt;&lt; sideb &lt;&lt; "\n" &lt;&lt; std::endl;
    }
    else if(sidec == 0){
        sidec = sqrt(pow(sidea,2) + pow(sideb,2));
        std::cout &lt;&lt; "side c= " &lt;&lt; sidec &lt;&lt; "\n" &lt;&lt; std::endl;
    }
    else{
        std::cout &lt;&lt; "\nYou must enter zero for an unknown side length.\n" &lt;&lt; std::endl;
        continue;
    }

    //This conditional branch checks to see if the user wants to exit. 
    if(sidea == 0 and sideb == 0 and sidec == 0)
        break;
    else
        continue;

}
return 0;
};
Holy comments Batman!

You have too many useless comments which makes your code harder to follow. 


  Comments should explain why something is done, not what is done.


Good code makes it obvious what is done, if you feel that you need to comment what is being done then your code can be improved instead. 

I'm going to link an answer to another question that explains commenting in a very good way (IMHO).

Prefer &amp;&amp; to and

This code if(sidea == 0 and sideb == 0 and sidec == 0) had me do a double take, the and totally threw me off as I'm very used to see &amp;&amp; used instead.

Keep it simple

One simplification you can make is to change bool error_check() into float read_real(). You should also extract your exit critera into a function and use it as a loop condition instead of breaking out of an infinite loop. This makes it much more clearer and removes the need for the comment. You can also extract computations from the conditional block when calculating the unknown side.

Like this:

float read_real(){
    float ans;
    std::cin &gt;&gt; ans;
    if(!std::cin){
        std::cin.clear();
        std::cin.ignore(256,'\n');
        throw std::invalid_argument("Please enter a real number");
    }
    return ans;
};

bool should_exit(float a, float b, float c){
    return a == 0 &amp;&amp; b == 0 &amp;&amp; c == 0;
}

...

float sidea = 1.0f;
float sideb = 1.0f;
float sidec = 1.0f;
while(!should_exit(sidea, sideb, sidec)){
    try{
        std::cout &lt;&lt; "side a: "; 
        sidea = read_real();

        std::cout &lt;&lt; "side b: ";
        sideb = read_real();

        std::cout &lt;&lt; "side c: ";
        sidec = read_real();

        // The unknown side must be 0, so this will work for all cases.
        float unknown = sqrt(abs(sidea*sidea + sideb*sideb - sidec*sidec));
        if(sidea == 0){
            std::cout &lt;&lt; "side a= " &lt;&lt; unknown &lt;&lt; "\n" &lt;&lt; std::endl;
        }
        else if(sideb == 0){
            std::cout &lt;&lt; "side b= " &lt;&lt; unknown &lt;&lt; "\n" &lt;&lt; std::endl;
        }
        else if(sidec == 0){
            std::cout &lt;&lt; "side c= " &lt;&lt; unknown &lt;&lt; "\n" &lt;&lt; std::endl;
        }
        else{
            throw std::invalid_argument("You must enter zero for an unknown side length.");
        }
    } catch (std::invalid_argument e){
        std::cout&lt;&lt;"\n Error: "&lt;&lt;e.what()&lt;&lt;std::endl;
    }
}