1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sladkih [1.3K]
3 years ago
6

In this exercise, you will write a Point structure that represents a space in two-dimensional space. This Point should have both

x and y elds (please use these exact names). You will also write three functions for dealing with Points; freadPoint, manhattanDistance, and euclideanDistance. freadPoint should take in a FILE handle and a Point (by reference) that it will initialize; it should not do any prompting. It will return true if it succeeds in reading a point and false if it fails. Each point will be a line in the le, with the x and y coordinates separated by spaces. A sample input le, point29.txt has been included. The manhattanDistance function will take two Points and compute the Manhattan distance (city block distance) between them, which is the distance that you would travel if you are restricted to walking parallel to either the x or y axes. Likewise, the euclideanDistance function will take two Points and compute the Euclidean distance (straight-line distance) between them. Neither function prints anything; they simply return a value. Your main function will prompt the user to enter two points and then display the Manhattan and Euclidean distances. You should call each of your functions (using stdio as a parameter to freadPoint) to do so. You may want to use the fabs and sqrt functions to help you with this assignment

Engineering
1 answer:
Afina-wow [57]3 years ago
8 0

Answer:

Check the explanation

Explanation:

Points to consider:

We need to take the input from the user

We need to find the manhatan distance and euclidian using the formula

(x1, y1) and (x2, y2) are the two points

Manhattan:

|x_1 - x_2| + |y_1 - y_2|

Euclidian Distance:

\sqrt{(x1 - yl)^2 + (x2 - y2)^2)}

Code

#include<stdio.h>

#include<math.h>

struct Point{

  int x, y;

};

int manhattan(Point A, Point B){

  return abs(A.x - B.x) + abs(A.y- B.y);

}

float euclidean(Point A, Point B){

  return sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2));

}

int main(){

  struct Point A, B;

  printf("Enter x and Y for first point: ");

  int x, y;

  scanf("%d%d", &x, &y);

  A.x = x;

  A.y = y;

  printf("Enter x and Y for second point: ");

  scanf("%d%d", &x, &y);

  B.x = x;

  B.y = y;

  printf("Manhattan Distance: %d\n", manhattan(A, B));

  printf("Euclidian Distance: %f\n", euclidean(A, B));

 

}

Sample output

You might be interested in
A bridge to be fabricated of steel girders is designed to be 500 m long and 12 m wide at ambient temperature (assumed 20°C). Exp
Volgvan

Answer:

a) 22.5number

b) 22.22 m length

Explanation:

Given data:

Bridge length = 500 m

width of bridge = 12 m

Maximum temperature = 40 degree C

minimum temperature  = - 35 degree C

Maximum expansion can be determined as

\Delta L = L \alpha (T_{max} - T_{min})

where , \alpha is expansion coefficient = 12\times 10^{-6} degree C

SO, \Delta L = 500\times 12\times 10^{-6}\times ( 40 - (-35))

\Delta L = 0.45 m = 450 mm

number of minimum expansion joints is calculated as

n = \frac{450}{20} = 22.5

b) length of each bridge

Length = \frac{500}{22.5} = 22.22 m

8 0
3 years ago
While discussing VIN numbers, Technician A says that the first digit of the VIN identifies the country where the vehicle was man
ruslelena [56]
Usually the first digit of the vin id’s the country it was built. So technician A would be correct. That’s usually how it is. Hope this helps. Please let me know if this is incorrect
4 0
3 years ago
Assume the impedance of a circuit element is Z = (3 + j4) Ω. Determine the circuit element’s conductance and susceptance.
djyliett [7]

Answer:

B. G = 333 mS, B = j250 mS

Explanation:

impedance of a circuit element is Z = (3 + j4) Ω

The general equation for impedance

Z = (R + jX) Ω

where

R = resistance in ohm

X = reactance

R = 3Ω  X = 4Ω

Conductance = 1/R while Susceptance = 1/X

Conductance = 1/3 = 0.333S

= 333 mS

Susceptance = 1/4 = 0.25S

= 250mS

The right option is B. G = 333 mS, B = j250 mS

8 0
3 years ago
Hello , how are yall:))))
SVEN [57.7K]

Answer:

eh I'm good hbu?????????

6 0
2 years ago
Read 2 more answers
To compute the energy used by a motor, multiply the power that it draws by the time of operation. Con- sider a motor that draws
ehidna [41]

Answer:

E=52000Hp.h

E=38724920Wh

E=1.028x10^11 ftlb

Explanation:

To solve this problem you must multiply the engine power by the time factor expressed in h / year, to find this value you must perform the conventional unit conversion procedure.

Finally, when you have the result Hp h / year you convert it to Ftlb and Wh

E=(12.5hp)(\frac{16h}{day} )(\frac{5 days}{week} )(\frac{52week}{year} )\\

E=52000Hp.h

E=52000Hp.h(\frac{744.71Wh}{Hp.h} )\\

E=38724920Wh

E=52000Hph(\frac{1977378.4  ft lb}{1Hph}

E=1.028x10^11 ftlb

3 0
3 years ago
Other questions:
  • Consider a fan located in a 3 ft by 3 ft square duct. Velocities at various points at the outlet are measured, and the average f
    12·1 answer
  • Select the correct answer.
    12·2 answers
  • 7. Which power source is an important transition between
    7·1 answer
  • The elastic settlement of an isolated single pile under a working load similar to that of piles in the group it represents, is p
    8·1 answer
  • A pressure gage at the inlet to a gas compressor indicates that the gage pressure is 40.0 kPa. Atmospheric pressure is 1.01 bar.
    5·1 answer
  • The concrete canoe team does some analysis on their design and calculates that they need a compressive strength of 860 psi. They
    15·1 answer
  • Prelest! Introduction to Engineering and Technology 1 Select the correct answer. What technological invention allowed for the pr
    5·1 answer
  • QUESTION:
    13·1 answer
  • At a certain location, wind is blowing steadily at 7 m/s. Determine the mechanical energy of air per unit mass and the power gen
    14·1 answer
  • Oil system cleaning products should not use solvents problem
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!