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
Air at 293k and 1atm flow over a flat plate at 5m/s. The plate is 5m wide and 6m long. (a) Determine the boundary layer thicknes
loris [4]

Answer:

a). 8.67 x 10^{-3} m

b).0.3011 m

c).0.0719 m

d).0.2137 N

e).1.792 N

Explanation:

Given :

Temperature of air, T = 293 K

Air Velocity, U = 5 m/s

Length of the plate is L  = 6 m

Width of the plate is b = 5 m

Therefore Dynamic viscosity of air at temperature 293 K is, μ = 1.822 X 10^{-5} Pa-s

We know density of air is ρ = 1.21 kg /m^{3}

Now we can find the Reyonld no at x = 1 m from the leading edge

Re = \frac{\rho .U.x}{\mu }

Re = \frac{1.21 \times 5\times 1}{1.822\times 10^{-5} }

Re = 332052.6

Therefore the flow is laminar.

Hence boundary layer thickness is

δ = \frac{5.x}{\sqrt{Re}}

   = \frac{5\times 1}{\sqrt{332052.6}}

   = 8.67 x 10^{-3} m

a). Boundary layer thickness at x = 1 is δ = 8.67 X 10^{-3} m

b). Given Re = 100000

    Therefore the critical distance from the leading edge can be found by,

     Re = \frac{\rho .U.x}{\mu }

     100000 = \frac{1.21\times5\times x}{1.822 \times10^{-5}}

     x = 0.3011 m

c). Given x = 3 m from the leading edge

    The Reyonld no at x = 3 m from the leading edge

     Re = \frac{\rho .U.x}{\mu }

     Re = \frac{1.21 \times 5\times 3}{1.822\times 10^{-5} }

     Re = 996158.06

Therefore the flow is turbulent.

Therefore for a turbulent flow, boundary layer thickness is

    δ = \frac{0.38\times x}{Re^{\frac{1}{5}}}

       = \frac{0.38\times 3}{996158.06^{\frac{1}{5}}}

       = 0.0719 m

d). Distance from the leading edge upto which the flow will be laminar,

  Re = \frac{\rho \times U\times x}{\mu }

5 X 10^{5} = \frac{1.21 \times 5\times x}{1.822\times 10^{-5}}}

 x = 1.505 m

We know that the force acting on the plate is

F_{D} = \frac{1}{2}\times C_{D}\times \rho \times A\times U^{2}

and C_{D} at x= 1.505 for a laminar flow is = \frac{1.328}{\sqrt{Re}}

                                                                         = \frac{1.328}{\sqrt{5\times10 ^{5}}}

                                                                       = 1.878 x 10^{-3}

Therefore, F_{D} =  \frac{1}{2}\times C_{D}\times \rho \times A\times U^{2}

                                          = \frac{1}{2}\times 1.878\times 10^{-3}\times 1.21\times (5\times 1.505)\times 5^{2}

                                         = 0.2137 N

e). The flow is turbulent at the end of the plate.

  Re = \frac{\rho \times U\times x}{\mu }

       = \frac{1.21 \times 5\times 6}{1.822\times 10^{-5} }

       = 1992316

Therefore C_{D} = \frac{0.072}{Re^{\frac{1}{5}}}

                                           = \frac{0.072}{1992316^{\frac{1}{5}}}

                                           = 3.95 x 10^{-3}

Therefore F_{D} = \frac{1}{2}\times C_{D}\times \rho\times A\times U^{2}

                                           = \frac{1}{2}\times 3.95\times 10^{-3}\times 1.21\times (5\times 6)\times 5^{2}

                                          = 1.792 N

3 0
3 years ago
To increase the thermal efficiency of a reversible power cycle operating between thermal reservoirs at TH and Tc, would you incr
alukav5142 [94]

<u></u>\ T_{c} has greater effect.

<u>Explanation</u>:

\eta_{\max }=1-\frac{T_{c}}{T_{A}}

T_{c}\\ = Temperature of cold reservoir

T_{H} = Temperature of hot reservoir

when T_{c} is decreased by 't',

$\eta_{\text {incre }}$ = 1-\frac{\left(\tau_{c}-t\right)}{T_{H}}

=n \ + \frac{t}{T_{n}}      -(i)

when {T_{H}} is increased by 'T'

\eta_{i n c}=\frac{n+\frac{t}{T_{H}}}{\left(1+\frac{k}{T_{H}}\right)}-(ii)

\eta_{\text {incre }} \ T_{c}>\eta_{\text {incre }} T_{\text {H }}

7 0
3 years ago
Engineering Careers Scavenger Hunt
emmasim [6.3K]

Answer:

c

Explanation:

it's the only engineering career

6 0
3 years ago
Read 2 more answers
.The war of the currents in the 1880's involved Thomas Edison and Nikola Tesla on a reality TV show stranded on an island. Each
natali 33 [55]

Answer:

True

Explanation:

Nikola Tesla defeated Thomas Edison in the AC/DC battle of electric current.

7 0
3 years ago
Technician A says that a defective crankshaft position sensor can cause a no spark condition technician B says that a faulty ign
Aliun [14]
Both tech distributor ignition
5 0
3 years ago
Other questions:
  • Amplifiers are extensively used in the baseband portion of a radio receiver system to condition the baseband signal to produce a
    5·1 answer
  • How do you connect several springs to increase the equivalent stiffness? What is one example from industry or other real-life si
    7·1 answer
  • WHAT IS THE MOST POWERFUL PART IN A CAR
    13·2 answers
  • Mining is an example of this type of business
    7·1 answer
  • The diameter of a cylindrical water tank is Do and its height is H. The tank is filled with water, which is open to the atmosphe
    11·1 answer
  • WHICH TASK BEST FITS THE ROLE OF A DESIGN ENGINEER ?
    7·1 answer
  • Pay attention to the following questions!
    14·1 answer
  • How would I find the Voltage across the open circuit
    7·1 answer
  • The primary of an ideal transformer has 400 turns and its secondary has 200 turns. Neglecting electrical losses, if the power in
    7·1 answer
  • Conduct online research and write a short report on the origin and evolution of the meter as a measurement standard. Discuss how
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!