Skip to content
sqrt function not defined in the math.h header?
Profile icon
bvernon2

working a Lab for class including the math.h function but it gives an error when using the sqrt function. the code runs fine in other online compilers, but i prefer to use repl.it

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

int main ()
{
float baseA, baseB, height, perimeter;
printf("Enter the first base of the trapezoid: \n");
scanf("%f", &baseA);
printf("Enter the second base of the trapezoid: \n");
scanf("%f", &baseB);
printf("Enter the height of the trapezoid: \n");
scanf("%f", &height);
perimeter = sqrt (heightheight + (baseA - baseB)(baseA - baseB));
printf("Perimeter is : %f\n", perimeter);
return 0;
}

it returns error:
exit status 1
/tmp/cc8huUt7.o: In function 'main':
main.c: (.test+0xbd): undefined reference to 'sqrt'
collect2: error: ld returned 1 exit status

You are viewing a single comment. View All
Profile icon
camiloalmendra1

So, math.h functions are not available in Replit?