Returning
true
orfalse
bool valid_triangle(float x, float y, float z);
int main(void)
{
float a = get_float("Enter the 1st Value : \n");
float b = get_float("Enter the 2nd Value : \n");
float c = get_float("Enter the 3rd Value : \n");
return valid_triangle(a,b,c);
}
bool valid_triangle(float x, float y, float z)
{
if(x <= 0 || y <= 0 || z <= 0 )
{
return false;
}
if((x + y <= z) || (x + z <= y) || (z + y <= x))
{
return false;
}
return true;
}
Change:
return valid_triangle(a,b,c);
to:
bool result = valid_triangle(a,b,c);
printf("%d\n", result);
Explanation: the C11 standard mentions these two valid signatures of main
function:
int main(void);
int main(int argc, char* argv[]);
None of them doesn't return bool
.