 # Trying to create a simple program calculating the sum of sides of a triangle

Hi, I`m just getting started with learning programming and recently I got stuck with this code

``````#include <cs50.h>
#include <stdio.h>
#include <float.h>

float valid_triangle (float a, float b, float c);
int main(void)

{
//ask for the sides of the triangle
printf ("The side x is: ");
int x = GetInt();
printf ("The side y is: ");
int y = GetInt();
printf ("The side z is: ");
int z = GetInt() ;
//calculate their sum
float s = valid_triangle ( x,  y,  z);

}

if (x+y<z || x+z<y || z+y<x || x<0 || y<0 || z<0)
{
printf ("Non valid variables");
}
else
{
printf ("the sum of %i, %i, %i is %i\n", x, y, z, s)
}
float valid_triangle (float a, float b, float c)
{
float sum = a+b+c;
return sum;
}
``````

Namely I cannot compile it and keep on getting the following error

~/workspace/ \$ make string
clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow string.c -lcrypt -lcs50 -lm -o string
string.c:4:49: error: expected ‘;’ after top level declarator
float valid_triangle (float a, float b, float c)
^
;
string.c:16:10: error: unused variable ‘s’ [-Werror,-Wunused-variable]
float s = valid_triangle ( x, y, z);
^
string.c:20:4: error: expected identifier or ‘(’
if (x+y<z || x+z<y || z+y<x || x<0 || y<0 || z<0)

If somebody know what`s the deal please let me know what is the thing I`m doing wrong. Thank you

You closed the main function a little early. Check your braces. That if else part isn't inside a function.

(deleted)

Thank you Delta_G!