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
How can any student outside apply for studying engineering at Cambridge University​
telo118 [61]
Admission to the Engineering course at Cambridge is highly competitive, both in terms of the numbers and quality of applicants. In considering applicants, Colleges look for evidence both of academic ability and of motivation towards Engineering. There are no absolute standards required of A Level achievement, but it should be noted that the average entrant to the Department has three A* grades. You need to get top marks in Maths and Physics.All Colleges strongly prefer applicants for Engineering to be taking a third subject that is relevant to Engineering.
Hope that helps and good luck if you are applying. Can you please mark this as brainliest and press the thank you button and if you have any further questions please let me know!!
3 0
3 years ago
Consider a plane composite wall that is composed of two materials of thermal conductivities kA = 0.1 W/m*K and kB = 0.04 W/m*K a
nadya68 [22]

Answer:

q=39.15 W/m²

Explanation:

We know that

Thermal resistance due to conductivity given as

R=L/KA

Thermal resistance due to heat transfer coefficient given as

R=1/hA

Total thermal resistance

R_{th}=\dfrac{L_A}{AK_A}+\dfrac{L_B}{AK_B}+\dfrac{1}{Ah_1}+\dfrac{1}{Ah_2}+\dfrac{1}{Ah_3}

Now by putting the values

R_{th}=\dfrac{0.01}{0.1A}+\dfrac{0.02}{0.04A}+\dfrac{1}{10A}+\dfrac{1}{20A}+\dfrac{1}{0.3A}

R_{th}=4.083/A\ K/W

We know that

Q=ΔT/R

Q=\dfrac{\Delta T}{R_{th}}

Q=A\times \dfrac{200-40}{4.086}

So heat transfer per unit volume is 39.15 W/m²

q=39.15 W/m²

4 0
3 years ago
wo companies, Ajax Co. and Boho Inc., were negotiating a merger. In the course of the negotiations, an Ajax representative told
boyakko [2]

Answer:

Yes

Explanation:

If the Ajax representative fails to correct the previous statement this can cause misrepresentation.

4 0
3 years ago
An automated transfer line is to be designed. Based on previous experience, the average downtime per occurrence = 5.0 min, and t
IRINA_888 [86]

Answer:

a) 28 stations

b) Rp = 21.43

E = 0.5

Explanation:

Given:

Average downtime per occurrence = 5.0 min

Probability that leads to downtime, d= 0.01

Total work time, Tc = 39.2 min

a) For the optimum number of stations on the line that will maximize production rate.

Maximizing Rp =minimizing Tp

Tp = Tc + Ftd

=  \frac{39.2}{n} + (n * 0.01 * 5.0)

= \frac{39.2}{n} + (n * 0.05)

At minimum pt. = 0, we have:

dTp/dn = 0

= \frac{-39.2}{n^2} + 0.05 = 0

Solving for n²:

n^2 = \frac{39.2}{0.05} = 784

n = \sqrt{784} = 28

The optimum number of stations on the line that will maximize production rate is 28 stations.

b) Tp = \frac{39.2}{28} + (28 * 0.01 * 5)

Tp = 1.4 +1.4 = 2.8

The production rate, Rp =

\frac{60min}{2.8} = 21.43

The proportion uptime,

E = \frac{1.4}{2.8} = 0.5

3 0
3 years ago
If the slotted arm rotates counterclockwise with a constant angular velocity of thetadot = 2rad/s, determine the magnitudes of t
astraxan [27]

Answer:

Magnitude of velocity=10.67 m/s

Magnitude of acceleration=24.62 ft/s^{2}

Explanation:

The solution of the problem is given in the attachments

3 0
3 years ago
Other questions:
  • A bar of 75 mm diameter is reduced to 73mm by a cutting tool while cutting orthogonally. If the mean length of the cut chip is 7
    10·1 answer
  • Water flows at a rate of 10 gallons per minute in a new horizontal 0.75?in. diameter galvanized iron pipe. Determine the pressur
    8·1 answer
  • Whats the best used for Arch bridge
    11·1 answer
  • In Josiah Johnson Hawes and Albert Sands Southworth, Early Operation under Ether, Massachusetts General Hospital the elevated vi
    11·1 answer
  • The rainfall rate in a certain city is 20 inches per year over an infiltration area that covers 33000 acres. Twenty percent of t
    6·1 answer
  • Digital leaders are people who __ others down a particular path.
    13·2 answers
  • A manufacturer has been asked to produce 100 customized metal discs with a particular pattern engraved on them. Which production
    10·2 answers
  • Identify five safety hazards that should be included in the design of the school
    6·1 answer
  • What’s the answer to this I don’t understand
    14·1 answer
  • A machine has an efficiency of 15%. If the energy input is 300 joules, how much useful energy is generated?(1 point).
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!