Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

0 1 . 0 2 . Calculate closer distance Problem Statement 0 2 You are given a function, int Distance ( int Ax , int

01.02. Calculate closer distance Problem Statement 02 You are given a function, int Distance (int Ax, int Ay, int Bx, int By); 03. The function accepts the coordinates of truck A(Ax, Ay) and the coordinates of truck B(Bx, By), as input. The office is at location (0,0). Implement the function to determine which truck is closer to the office by comparing the square of their distances. Return the square of the distance of the truck which is closer to the office. Square of distance between two points having coordinates (x, y) and (0,0): (Distance)2=[x2+ y2] Note: No need to compute the square root of the distances of trucks A and B from the office. If both trucks are at equal distance, return square of distance of either truck. Example: Input: 125129 Output: 169 Explanation: (Distance of truck A)2=[Ax2+ Ay2]=[122+52]=(144+25)=169(Distance of truck B)2=[Bx2+ By2]=[122+92]=(144+81)=225 Since, (169<225), hence the output is 169. ample input ple Output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

explain the concept of strategy formulation

Answered: 1 week ago