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
A square steel bar has a length of 8.4 ft and a 2.1 in by 2.1 in cross section and is subjected to axial tension. The final leng
nikitadnepr [17]

Answer:

Poissons ratio = -0.3367

Explanation:

Poissons ratio = Lateral Strain / Longitudinal Strain

In this case, the longitudinal strain will be:

Strain (longitudinal) = Change in length / total length

Strain (longitudinal) = (8.40392 - 8.4) / 8.4

Strain (longitudinal) = 4.666 * 10^(-4)

While the lateral strain will be:

Strain (Lateral) = Change in length / total length

Strain (Lateral) = (2.09967 - 2.1) / 2.1

Strain (Lateral) = -1.571 * 10^(-4)

Solving the poisson equation at the top we get:

Poissons ratio = -1.571 / 4.666                                     <u>( 10^(-4) cancels out )</u>

Poissons ratio = -0.3367

6 0
3 years ago
An overhead 25m-long, uninsulated industrial steam pipe of 100-mm diameter, is routed through a building whose walls and air are
wariber [46]

Answer:

1) q=18414.93 W

2) C=12920$

Explanation:

Given data:

pipe length L=25m

pipe diameter D=100mm =0.1 m

air temperature T_{s1}=T_{\infty1} }=25 °C.....= 298.15k

pipe surface temp T_{s2}=150 °C.....=423.15k

surface emissivity e= 0.8

boiler efficiency η=0.90

natural gas price Cg=$0.02 per MJ

1) Total heat loss and radiation heat loss combined

          q=q_{conv} +q_{rad}

          q=A[h(T_{s2}-T_{s1})+eб(T_{s2}^4-T_{s1}^4)]....... (1)

б=5.67×10^-8 W/m^2K^4 (boltzmann constant)

area A =L.Dπ=25×0.1π=7.85 m^2

putting all these values in eq (1)

q=18414.93 W

2) suppose boiler is operating non stop annual energy loss will be

               E=q.t

                  =18414.93.3600.24.365

                  =5.81×10^11 J

   to find furnace energy consumption

               Ef =E/η

                  =6.46×10^5 MJ

   annual cost

                  C=Cg. Ef

                    =12920$

8 0
3 years ago
Find the error in the following pseudo code
IRISSAK [1]

Pseudocodes are used as a prototype of an actual program.

The error in the pseudocode is that, the while loop in the pseudocode will run endlessly.

From the pseudocode, the first line is:

<em>Declare Boolean finished = false</em>

The while loop is created to keep running as long as <em>finished = false.</em>

So, for the while loop to end, the finished variable must be updated to true.

This action is not implemented in the pseudocode.

Hence, the error in the pseudocode is that, the while loop is an endless loop

Read more about pseudocodes at:

brainly.com/question/17442954

8 0
2 years ago
Our rule-of-thumb for presenting final results is to round to three significant digits or four if the first digit is a one. By t
olga_2 [115]

Answer:

To four significant digits = 2097 psi

Explanation:

<u>Applying the rule of thumb </u>

σ = Mc/I  ---- ( 1 )

M = 1835 Ibf in ,  I/c = 0.875 in^3

∴ c/l = 1 / 0.875 = 1.1429

back to equation 1

σ = 1835 * 1.1429 = 2097.2215 psi

To four significant digits = 2097 psi

4 0
3 years ago
In a particular application involving airflow over a heated surface, the boundary layer temperature distribution may be approxim
diamong [38]

Answer:

Explanation:

In a particular application involving airflow over a heated surface, the boundary layer temperature distribution, T(y), may be approximated as:

[ T(y) - Ts / T∞ - Ts ] = 1 - e^( -Pr (U∞y / v) )

where y is the distance normal to the surface and the Prandtl number, Pr = Cpu/k = 0.7, is a dimensionless fluid property. a.) If T∞ = 380 K, Ts = 320 K, and U∞/v = 3600 m-1, what is the surface heat flux? Is this into or out of the wall? (~-5000 W/m2 , ?). b.) Plot the temperature distribution for y = 0 to y = 0.002 m. Set the axes ranges from 380 to 320 for temperature and from 0 to 0.002 m for y. Be sure to evaluate properties at the film temperature.

3 0
4 years ago
Other questions:
  • How does the invention of electrical lights and automobiles impact the world today? Explain. (1 paragraph minimum)
    11·1 answer
  • Given a 8-bit ripple carry adder and the following four input scenarios: (i) A4 + 1F, (ii) AB+55, (iii) CA+34, (iv) 6D+29. a) Un
    5·2 answers
  • Hydrogen is preferred for regeneratively cooled nozzles because it is easy to pump. a)-True b)-False
    6·1 answer
  • Linear Time Invariant Systems For each of the systems below an input x(t) and the output y(t) are plotted. Determine whether eac
    5·1 answer
  • Given the vector current density J = 10rho2zarho − 4rho cos2 φ aφ mA/m2:
    13·1 answer
  • Water is leaking out of an inverted conical tank at a rate of 11700.0 cubic centimeters per min at the same time that water is b
    11·1 answer
  • A balanced three phase load is supplied over a three-phase , 60 hz, transmission line with each line have a series impedance of
    10·1 answer
  • Which two statements about professional technical jobs in the energy industry are correct?
    15·2 answers
  • It is desired to produce and aligned carbon fiber-epoxy matrix composite having a longitudinal tensile strength of 630 MPa. Calc
    6·1 answer
  • How does accenture generate value for clients through agile and devops?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!