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
thier only motto and goal is to work for society and not make any profits A.small business entreprenuership B.scalable start up
sweet-ann [11.9K]

Answer:

social entrepreneurship

8 0
3 years ago
Read 2 more answers
A 15.00 mL sample of a solution of H2SO4 of unknown concentration was titrated with 0.3200M NaOH. the titration required 21.30 m
natima [27]

Answer:

a. 0.4544 N

b. 5.112 \times 10^{-5 M}

Explanation:

For computing the normality and molarity of the acid solution first we need to do the following calculations

The balanced reaction

H_2SO_4 + 2NaOH = Na_2SO_4 + 2H_2O

NaOH\ Mass = Normality \times equivalent\ weight \times\ volume

= 0.3200 \times 40 g \times 21.30 mL \times  1L/1000mL

= 0.27264 g

NaOH\ mass = \frac{mass}{molecular\ weight}

= \frac{0.27264\ g}{40g/mol}

= 0.006816 mol

Now

Moles of H_2SO_4 needed  is

= \frac{0.006816}{2}

= 0.003408 mol

Mass\ of\ H_2SO_4 = moles \times molecular\ weight

= 0.003408\ mol \times 98g/mol

= 0.333984 g

Now based on the above calculation

a. Normality of acid is

= \frac{acid\ mass}{equivalent\ weight \times volume}

= \frac{0.333984 g}{49 \times 0.015}

= 0.4544 N

b. And, the acid solution molarity is

= \frac{moles}{Volume}

= \frac{0.003408 mol}{15\ mL \times  1L/1000\ mL}

= 0.00005112

=5.112 \times 10^{-5 M}

We simply applied the above formulas

4 0
3 years ago
help me please help me please help me please help me please help me please help me please help me please help me please help me
kakasveta [241]

Answer:

With what?

Explanation:

Brainliest?

7 0
3 years ago
Read 2 more answers
Calculate the volume of a hydraulic accumulator capable of delivering 5 liters of oil between 180 and 80 bar, using as a preload
Vinil7 [7]

Answer:

1) V_o = 10 liters

2) V_o = 12.26 liters

Explanation:

For isothermal process n =1

V_o =\frac{\Delta V}{(\frac{p_o}{p_1})^{1/n} -(\frac{p_o}{p_2})^{1/n}}

V_o  = \frac{5}{[\frac{72}{80}]^{1/1} -[\frac{72}{180}]^{1/1}}

V_o = 10 liters

calculate pressure ratio to determine correction factor

\frac{p_2}{p_1} =\frac{180}{80} = 2.25

correction factor for calculate dpressure ration  for isothermal process is

c1 = 1.03

actual \ volume = c1\times 10 = 10.3 liters

b) for adiabatic process

n =1.4

volume of hydraulic accumulator is given as

V_o =\frac{\Delta V}{[\frac{p_o}{p_1}]^{1/n} -[\frac{p_o}{p_2}]^{1/n}}

V_o  = \frac{5}{[\frac{72}{80}]^{1/1.4} -[\frac{72}{180}]^{1/1.4}}

V_o = 12.26 liters

calculate pressure ratio to determine correction factor

\frac{p_2}{p_1} =\frac{180}{80} = 2.25

correction factor for calculate dpressure ration  for isothermal process is

c1 = 1.15

actual \volume = c1\times 10 = 11.5 liters

8 0
3 years ago
Assume the work done compressing the He gas is -63 kJ and the internal energy change of the gas is 79 kJ. What is the heat loss
klemol [59]

Answer:

Heat gain of 142 kJ

Explanation:

We can see that job done by compressing the He gas is negative, it means that the sign convention we are going to use is negative for all the work done by the gas and positive for all the job done to the gas. With that being said, the first law of thermodynamics equation will help us to solve this problem.

ΔU = Q + W ⇒ Q = ΔU -W

Q = 79 - (-63) = 142 kJ

Therefore, the gas gained heat by an amount of 142 kJ.

3 0
3 years ago
Other questions:
  • How an AK 47 gun was works​
    14·1 answer
  • A heat pump designer claims to have an air-source heat pump whose coefficient of performance is 1.8 when heating a building whos
    10·1 answer
  • Turbine blades mounted to a rotating disc in a gas turbine engine are exposed to a gas stream that is at [infinity] = 1100°C and
    6·1 answer
  • A process consists of two steps: (1) One mole of air at T = 800 K and P = 4 bar is cooled at constant volume to T = 350 K. (2) T
    7·1 answer
  • In sleep, what does REM stand for?
    10·1 answer
  • A 40kg steel casting (Cp=0.5kJkg-1K-1) at a temperature of 4500C is quenched in 150kg of oil (Cp=2.5kJkg-1K-1) at 250C. If there
    13·1 answer
  • You talk with the owner and he likes the idea of using two large glulam beams as shown to carry the joist loads. Design the glul
    5·1 answer
  • What is aviation? What is the difference between aviation and flight?
    9·1 answer
  • For RTK to work, what do we need besides two or more receivers collecting data from a sufficient number of satellites simultaneo
    11·1 answer
  • Select the correct answer.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!