**PROBLEM CODE**

VIEW2002

**PROBLEM LINK:**

https://www.codechef.com/QTCC2020/problems/VIEW2002

**DIFFICULTY:**

Easy

**PREREQUISITES**:

math

**PROBLEM :**

The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at the location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to the office.

**EXPLANATION**:

The first line of the data set for this problem is an integer representing the number of collections of data that follow. Each collection contains 4 integers: the x-coordinate and then the y-coordinate of truck A followed by the x-coordinate and then the y-coordinate of truck B.All letters are upper case. The output is to be formatted exactly like that for the sample output given below.

The x-coordinate is in the range –20 … 20. The y-coordinate is in the range –20 … 20.The distance between point # 1 with coordinates (x1, y1) and point #2 with coordinates (x2, y2) .

**SOLUTIONS**:

## Summary

#include<stdio.h>

#include<math.h>

int main ()

{

int dataSet;

scanf (“%d”, &dataSet);

```
while ( dataSet-- ) {
double xA, yA;
scanf ("%lf %lf", &xA, &yA);
double xB, yB;
scanf ("%lf %lf", &xB, &yB);
double distance_A = sqrt ( xA * xA + yA * yA );
double distance_B = sqrt ( xB * xB + yB * yB );
if ( distance_A > distance_B )
printf ("B IS CLOSER\n");
else
printf ("A IS CLOSER\n");
}
return 0;
```

}

Feel free to Share your approach.Suggestions are welcomed as always had been.