math.h error => C language

I don't know how to implement sqrt() function in C languge.
Every time I call a compiler I get this error

function sqrt not declared 

I looked at C standard libray reference and from my perspective everthing is O.K

Here is the code

// Program asks user to enter the sides of the triangle
// and then test if triangle is isoscelesm , right-angled, equilateral
// Solution for exercise 17 (chapter 5)
// Date of creation: 15/02/2011

#include <stdio.h> 
#include <math.h>

int main(void) {
    
    float a,b,c;
    
    // Asks user to enter sides
    
    printf("\t\tTriangle detection triangle\n");
    printf("Enter three sides of the triangle: ");
    scanf("%f, %f, %f", &a, &b, &c);
    
    if (a <= 0 || b <= 0 || c <= 0) {
        printf("Invalid input\n");
        return 1;
        }
    else if (a + b > c && a + c > b && b + c > a) {
        printf("Valid entry!\n");
        }
    if ( a != b && a != c && b != a && b != c && c != a) {
        printf("isoscelesm\n");
        }
    else if ( a == b && a == c ) { 
        printf("equilateral\n");
        }
    else if ( b == a && b == c ) {
        printf("equilateral\n");
        }
    else if ( c == a && c == b) {
        printf("equilateral\n");
        }
    else if (c == sqrt (a * a  + b * b)) {
        printf("equilateral\n");
        }
    
    return 0;
}
cc -o myprog  myprog.c -lm

Try this and report back what you get.

It compiled under Linux, under Solaris doesn't pass compilation.

Thnx

In what manner did it not "pass compilation"? I left my crystal ball at home today.

You should also realize that "==" isn't really meant for floating point numbers. It will only return true when the values are exactly, exactly the same to a ludicrous degree of precision you'll likely never find in real life. For instance, this code fails on my system:

        if((10000000000000001.0-10000000000000000.0) == 1.0)
        {
                printf("equal\n");
        }

The greater or less-than operators are safe though, so if(abs(b-c) < 0.000001) will be better behaved than if(b==c) . Pick a small enough value of 0.000...1 to match the level of precision you want.

What are the exact errors? What's the exact command you're using to try and compile?

I wrong typed command :rolleyes:

Everything works, plase lock the theme