0
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

// PROTOTYPE THE FUNCTON

bool valid_triangle(float input1, float input2, float input3);

// RUN THE MAIN PROGRAMME

int main(void)  {

            //DECLARE THE VARIABLES WITHIN THE MAIN PROGRAMME FUNCTION FOR USE IN OTHER FUNCTIONS WITHIN MAIN

            float input1;
            float input2;
            float input3;

            printf("give me 3 positive real numbers\n");

                do {

                    input1 = get_float("Integer 1: ");
                    input2 = get_float("Integer 2: ");
                    input3 = get_float("Integer 3: ");

                    }

            while ((input1 || input2 || input3) <= 0);

            if (valid_triangle(input1, input2, input3) == false)

                {

                printf("unfortunately those values do not make a valid triangle");

                return false;

                }

            else {

                printf("great, those 3 numbers should make a valid triangle");

                return true;

                }


            }

bool valid_triangle(float input1, float input2, float input3) {

                                                                if ((input2 + input3) >= input1) || 
((input3 + input1) >= input2) || ((input1 + input2) >= input3))

                                                                    {

                                                                    return false;

                                                                    }

                                                                else
                                                                    {

                                                                    return true;

                                                                    }

                                                            }

errors:

valid_triangle.c:56:101: error: expected expression
                                                                if ((input2 + input3) > input1) || 
((input3 + input1) > input2) || ((input1 + input2) > input3));
                                                                                                ^

1 error generated.
<builtin>: recipe for target 'valid_triangle' failed
make: *** [valid_triangle] Error 1
0

You just have the bracket misplaced:

if ((input2 + input3) >= input1 || (input3 + input1) >= input2 || (input1 + input2) >= input3)
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .