Hi
I'm a newbie, I'm trying to understand c programing language. But I have an issue. Why do I get this error?
rootsquer.c
Code:
#include <math.h>
#include <stdio.h>
int main() {
double number, squareRoot;
printf("Enter a number: ");
scanf("%lf", &number);
// computing the square root
squareRoot = sqrt(number);
printf("Square root of %.2lf = %.2lf", number, squareRoot);
return 0;
}
Code:
$ clang -ansi rootsquer.c -o rootsquer
/usr/bin/ld: /tmp/rootsquer-fe5919.o: in function `main':
rootsquer.c:(.text+0x41): undefined reference to `sqrt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)