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 T1 = 32°C, p1 = 1 bar, 50% relative humidity enters an insulated chamber operating at steady state with a mass flow rate
RUDIKE [14]

Answer:

4.5kg/min

Explanation:

Given parameters

T_1 = 32^0 C,  m_1 = 3 kg/min, T_2 = 7^0 C ,T_3 = 17^0

if we take  

The mass flow rate of the second stream = m_2(kg/min)

The mass flow rate of mixed exit stream = m_3 (kg/min)

Now from mass conservation

m_3 = m_2 + m_1

m_3 = m_2 + 3 (kg/min)

The temperature of the mixed exit stream given as

T_3m_3 = T_2m_2 +T_1m_1\\\\17 ( 3 + m_2) = 7 \times m_2 + 32 \times 3\\\\51 + 17 m_2 = 7 m_2 + 96\\\\10 m_2 = 96 - 51\\\\m_2 = 4.5 kg/min\\\\\\\\

Therefore the mass flow rate of second stream will be 4.5 kg/min.

7 0
3 years ago
Carbon dioxide initially at 50 kPa, 400 K, undergoes a process in a closed system until its pressure and temperature are 2 MPa a
Elena L [17]

Answer:

$ S_2 - S_1 = -0.1104 \: \: kJ/kg.K$

The entropy change of the carbon dioxide is -0.1104 kJ/kg.K

Explanation:

We are given that carbon dioxide undergoes a process in a closed system.

We are asked to find the entropy change of the carbon dioxide  with the assumption that the specific heats are constant.

The entropy change of the carbon dioxide is given by

$ S_2 - S_1 = C_p \ln (\frac{T_2}{T_1}) - R\ln (\frac{P_2}{P_1}) $

Where Cp is the specific heat constant

Cp = 0.846 kJ/kg.K

R is the universal gas constant

R = 0.1889 kJ/kg.K

T₁ and T₂ is the initial and final temperature of carbon dioxide.

P₁ and P₂ is the initial and final pressure of carbon dioxide.

$ S_2 - S_1 = 0.846 \ln (\frac{800}{400}) - 0.1889\ln (\frac{2000}{50}) $

$ S_2 - S_1 = 0.846(0.69315) - 0.1889(3.6888) $

$ S_2 - S_1 = 0.5864 - 0.6968 $

$ S_2 - S_1 = -0.1104 \: \: kJ/kg.K$

Therefore, the entropy change of the carbon dioxide is -0.1104 kJ/kg.K

6 0
2 years ago
A(n) 78-hp compressor in a facility that operates at full load for 2500 h a year is powered by an electric motor that has an eff
Jet001 [13]

Answer: $17,206.13

Explanation:

Hi, to answer this question we have to apply the next formula:  

Annual electricity cost = (P x 0.746 x Ckwh x h) /η  

P = compressor power = 78 hp  

0.746 kw/hp= constant (conversion to kw)

Ckwh = Cost per kilowatt hour = $0.11/kWh  

h = operating hours per year = 2500 h  

η = efficiency = 93% = 0.93 (decimal form)  

Replacing with the values given :  

C = ( 78 hp x 0.746 kw/hp x 0.11 $/kwh x 2500 h ) / 0.93 = $17,206.13  

5 0
3 years ago
where σ(t) and σ(0) represents the time-dependent and initial (i.e., time =0) stresses, respectively, and t and τ denote elapsed
artcher [175]

Answer:

MUDA MUDA A certain vehicle loses 3.5% of its value each year. If the vehicle has an initial value of $11,168, construct a model that represents the value of the vehicle after a certain number of years. Use your model to compute the value of the vehicle at the end of 6 years.

Explanation:

4 0
3 years ago
Explain the 3 examples of technology transfer
xxTIMURxx [149]

Answer:

ht f of tevno animation de espain ingleis

8 0
3 years ago
Other questions:
  • 3. (9 points) A square-thread power screw is used to raise or lower the basketball board in a gym, the weight of which is W = 10
    12·1 answer
  • Consider a regenerative gas-turbine power plant with two stages of compression and two stages of expansion. The overall pressure
    11·1 answer
  • For a turning operation, you have selected a high-speed steel (HSS) tool and turning a hot rolled free machining steel. Your dep
    9·1 answer
  • An air conditioning system operating on reversed carnot cycle is required to remove heat from the house at a rate of 32kj/s to m
    5·1 answer
  • Develop a chase plan that matches the forecast and compute the total cost of your plan. (Negative amounts should be indicated by
    5·1 answer
  • Significant figures are an indicator of accuracy. a) True b) False
    8·1 answer
  • Plz solve the problem
    7·1 answer
  • Giving out 100 coins cuz why not?​
    11·1 answer
  • Multiple Choice
    7·1 answer
  • 17
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!