Write a function that is called true_triangle that has three real sides and the numbers representing the three lengths sides of the triangle should be the arguments. The outputs should either be true or false depending on whether the three lengths are all capable of forming a true triangle.

N/B: Make sure the following rules are adhered to:

  1. The true triangle can only have lengths sides that are positive values
  2. The sum of any of the two lengths sides of the true triangle must be greater than the length of the third side of the true triangle.


booln true_triangle(float a, float b, float c);  // declaring a function
booln true_triangle(float a, float b, float c)    // defining the function
   // checking if all the three sides are positive values
   if (a <= 0 || b <= 0 || c <= 0)
       return false;                       // calling the function

   // checking if the sum of any of the two length sides of the triangle are greater than the third side
    if ((a + b <= c) || (a + c <= b) || (b + c <= a))
        return false;                    // calling the function
    // if both the two tests or rules were passed then

    return true;                           // calling the function

That’s it! Of course there are other ways of solving the problem, this is just one of the ways to solve it.

The goal is to understand the concepts of declaring a function, defining a function, and calling the function.


If you have any question or comment, do not hesitate to ask us.

Quote: The moon looks upon many night flowers; the night flowers see but one moon. – Jean Ingelow