- #1
SnakeDoc
- 27
- 1
Homework Statement
I have make a program that solves the distance between 2 points on a triangle.
Homework Equations
none
The Attempt at a Solution
Code:
/* homework 1 */
#include <stdio.h>
#include <math.h>
int main(void)
{
// Declare and initialize variables
float x1=1, y1=5, x2=4, y2=7;
float dx, dy, distance;
// Compute sides of a right triangle
dx = x2 - x1;
dy = y2 - y1;
distance = sqrt (dx*dx + dy*dy);
// Print distance
printf("The distance between the two points is: %5.2f \n",distance);
// Exit program
return(0);
}
I keep getting a an error about an undefined reference to sqrt
Did I do something wrong?
Last edited by a moderator: