Challenge - Calculate Distance Between Two Points
Problem Statement
- A struct Point is given which has two items,
x
andy
. - The function test is given which has two instances of points initialized with some value of
x
andy
. - The task is to calculate the distance between the two points.
The distance between two points is: √(x1−x2)2+(y1−y2)2
- Return the value of distance
input
Two instances of point
Output The output of the code should be:
The distance between x and y
Coding Exercise
struct Point {
x: i32,
y: i32
}
fn test(_point1: Point, _point2: Point)-> f32 {
// Write code here!
1.0
}
Good luck! 🤞