answer.
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]
2 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]2 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
What action below would tell your computer to "Send" an email?
Fynjy0 [20]
Click I think:) not sure tho
4 0
2 years ago
Read 2 more answers
Problem 5) Water is pumped through a 60 m long, 0.3 m diameter pipe from a lower reservoir to a higher reservoir whose surface i
kap26 [50]

Answer:

\epsilon = 0.028*0.3 = 0.0084

Explanation:

\frac{P_1}{\rho} + \frac{v_1^2}{2g} +z_1 +h_p - h_l =\frac{P_2}{\rho} + \frac{v_2^2}{2g} +z_2

where P_1 = P_2 = 0

V1 AND V2  =0

Z1 =0

h_P = \frac{w_p}{\rho Q}

=\frac{40}{9.8*10^3*0.2} = 20.4 m

20.4 - (f [\frac{l}{d}] +kl) \frac{v_1^2}{2g} = 10

we know thaTV  =\frac{Q}{A}

V = \frac{0.2}{\pi \frac{0.3^2}{4}} =2.82 m/sec

20.4 - (f \frac{60}{0.3} +14.5) \frac{2.82^2}{2*9.81} = 10

f  = 0.0560

Re =\frac{\rho v D}{\mu}

Re =\frac{10^2*2.82*0.3}{1.12*10^{-3}} =7.53*10^5

fro Re = 7.53*10^5 and f = 0.0560

\frac{\epsilon}{D] = 0.028

\epsilon = 0.028*0.3 = 0.0084

4 0
2 years ago
A curve in a speed track has a radius of 1000 ft and a rated speed of 120 mi/h. (From Sample Prob. 12.7 is the definition of rat
forsale [732]

Answer:

tan \theta = \frac{(176ft/s)^2}{1000 ft 32.2 ft/s^2}= 0.962

\theta = tan^{-1} (0.962) = 43.89

Explanation:

If the question is: Determine the banking angle θ

We have the forces involved on the figure attached.

For this case we know that the weight is given by:

W = mg

And for this case the centripetal acceleration would be given by:

a=\frac{v^2}{r}

If we analyze the sum of forces on x and y we have:

\sum F_x = m a_x

F + W sin \theta = ma cos theta

And if we solve for the force we got:

F = ma cos \theta - mg sin \theta = \frac{mv^2}{r} cos \theta - mg sin \theta

\sum F_y = m a_y

N - W cos \theta = ma sin \theta

If we solve for the normal force we got:

N =W cos \theta + ma sin \theta = \frac{mv^2}{r} sin \theta + mg cos \theta

In order to find the banking angle we use the fact that F =0

0 = \frac{mv^2}{r} cos \theta - mg sin \theta

tan \theta= \frac{v^2}{rg}

The velocity on this case is 120 mi/h if we convert this into ft/ s we got:

120 mi/h * \frac{5280 ft}{1mi} *\frac{1hr}{3600 s}= 176 ft/s

And then we have this:

tan \theta = \frac{(176ft/s)^2}{1000 ft 32.2 ft/s^2}= 0.962

\theta = tan^{-1} (0.962) = 43.89

5 0
2 years ago
A person puts a few apples into the freezer at -15oC to cool them quickly for guests who are about to arrive. Initially, the app
frosja888 [35]

Answer:

Temperature at center of apples = 11.2⁰C

Temperature at surface of apples = 2.7⁰C

Amount of Heat transferred = 17.2kJ

Explanation:

The properties of apple are given as:

k = 0.418 W/m.°C

ρ = 840 kg/m³

Cр = 3.81 kJ/kg.°C

α = 1.3*10 ⁻⁷ m²/s

h = 8 W/m².°C

d = 0.09m

r = 0.045m

t = 1 hour = 3600s

<h2>Solution</h2>

Biot number is given as:

Bi = \frac{hr}{k}= \frac{8\cdot0.045}{0.418}=0.861

The constants λ₁ and A₁ corresponding to Biot number (from the table) are:

λ₁ = 1.476

A₁ = 1.239

Fourier Number is:

T = \frac{a\cdot{t}}{r^2} = \frac{(1.3\cdot10^{-7})(3600)}{0.045^2}= 0.231> 0.2

As Fourier Number > 0.2 , one term approximates solutions are applicable

The temperature at the center of apples, The temperature at surface of apples and Amount of heat transfer is found in the ATTACHMENT.

8 0
2 years ago
Who want to play "1v1 lol unblocked games 76"
kotegsom [21]

Answer:I want to play what game?

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • You are working in a lab where RC circuits are used to delay the initiation of a process. One particular experiment involves an
    13·1 answer
  • Water has a density of 1.94 slug/ft^3. What is the density expressed in SI units? Express the answer to three significant figure
    8·1 answer
  • A long aluminum wire of diameter 3 mm is extruded at a temperature of 280°C. The wire is subjected to cross air flow at 20°C at
    9·1 answer
  • Air in a 10 ft3 cylinder is initially at a pressure of 10 atm and a temperature of 330 K. The cylinder is to be emptied by openi
    10·2 answers
  • The velocity distribution for laminar flow between parallel plates is given by u umax = 1 − ( 2y h ) 2 Where h is the distance s
    15·1 answer
  • Which of the following describes boundaries?
    10·1 answer
  • A rectangular beam having b=300 mm and d=575 mm, spans 5.5 m face to face of simple supports. It is reinforced for flexure with
    14·1 answer
  • Who play 1v1 lol unblocked games 76
    8·2 answers
  • How does Accenture generate value for clients through Agile and DevOps?
    15·2 answers
  • What term describes a guardrail system
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!