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
What major advancement in machine tools occurred in the 1970s and what benefits did it provide? describe in your own words.
mixer [17]

Answer:

I'm just a seventh grader

4 0
3 years ago
Read 2 more answers
How does a rudder help maneuver an airplane?
Nonamiya [84]
It’s just helps it like
4 0
3 years ago
Instead of running blood through a single straight vessel for a distance of 2 mm, one mammalian species uses an array of 100 tin
Marina CMI [18]

Solution:

Given that :

Volume flow is, $Q_1 = 1000 \ mm^3/s$

So, $Q_2= \frac{1000}{100}=10 \ mm^3/s$

Therefore, the equation of a single straight vessel is given by

$F_{f_1}=\frac{8flQ_1^2}{\pi^2gd_1^5}$    ......................(i)

So there are 100 similar parallel pipes of the same cross section. Therefore, the equation for the area is

$\frac{\pi d_1^2}{4}=1000 \times\frac{\pi d_2^2}{4} $

or $d_1=10 \ d_2$

Now for parallel pipes

$H_{f_2}= (H_{f_2})_1= (H_{f_2})_2= .... = = (H_{f_2})_{10}=\frac{8flQ_2^2}{\pi^2 gd_2^5}$  ...........(ii)

Solving the equations (i) and (ii),

$\frac{H_{f_1}}{H_{f_2}}=\frac{\frac{8flQ_1^2}{\pi^2 gd_1^5}}{\frac{8flQ_2^2}{\pi^2 gd_2^5}}$

       $=\frac{Q_1^2}{Q_2^2}\times \frac{d_2^5}{d_1^5}$

       $=\frac{(1000)^2}{(10)^2}\times \frac{d_2^5}{(10d_2)^5}$

       $=\frac{10^6}{10^7}$

Therefore,

$\frac{H_{f_1}}{H_{f_2}}=\frac{1}{10}$

or $H_{f_2}=10 \ H_{f_1}$

Thus the answer is option A). 10

7 0
3 years ago
I = 48 mA, R = 1125 2. What is Vs ?
german
54 volts

Ohms law. E= I x R
6 0
3 years ago
You are given a body with no body forces and told that the stress state is given as: ⎡ ⎣ 3αx 5βx2 + αy γz3 5βx2 + αy βx2 0 γz3 0
Lady bird [3.3K]

Answer:

This doesn't represent an equilibrium state of stress

Explanation:

∝ = 1 , β = 1 ,  y = 1

x = 0 , y = 0 , z = 0 ( body forces given as 0 )

Attached is the detailed solution is and also the conditions for equilibrium

for a stress state to be equilibrium all three conditions has to meet the equilibrum condition as explained in the attached solution

5 0
3 years ago
Other questions:
  • 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
    13·1 answer
  • Write a SELECT statement that returns the same result set as this SELECT statement. Substitute a subquery in a WHERE clause for
    10·1 answer
  • The flatbed truck carries a large section of circular pipe secured only by the two fixed blocks A and B of height h. The truck i
    14·2 answers
  • Some engineers have developed a device that provides lighting to rural areas with no access to grid electricity. The device is i
    13·1 answer
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • Consider a sinusoidal oscillator consisting of an amplifier having a frequency-independent gain A (where A is positive) and a se
    6·1 answer
  • Pls help! 39 points!!
    5·2 answers
  • Water at 20◦C is pumped through 1000 ft of 0.425 ft diameter pipe at a volumetric flowrate of 1 ft3/s through a cast iron pipe t
    14·1 answer
  • Which of the following is NOT a true statement about construction drawings?
    5·1 answer
  • 17. Swing arm restraints are intended to prevent a vehicle from falling off a lift.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!