Cs1325- write a program to find distance between the two


Assignment- Arrays and Parallel Arrays

Introduction

In this assignment you will write a small C program. Your program should compile correctly and produce the specified output.

Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author's name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions.

Program #1

Given the following list of point coordinates and label:

Point Label

X-Coordinate

Y-Coordinate

A

50.2

75.8

B

45.7

48

C

76.7

99.1

D

12

14

F

-25

48

G

23

-36

Table 1: Point Information

The information is given as three arrays:

i) A char array named point_label, for column 1 in Table 1
ii) A double array named x_coord, for column 2 in Table 1
iii) A double array named y_coord, for column 3 in Table 1

The table information can be hard coded.

Given two points, entered using the labels (i.e. A and B), the program will compute:

a) The distance between the two points
b) The equation of the line crossing these points in the form: y = mx+k
c) The closest perpendicular point to the line described by the two points given.

The distance from a point P0(x0,y0) to a line in the form ax+by+c=0 , is defined as:

distance (ax+by+c=0, P0) = |ax0+by0+c| / √(a2+b2)

Where a and b are not both zero.

Introduction to Programming Assignment: Arrays and Parallel Arrays

The program should display a menu (10 points) with the following options:

a) Enter points (5 points)
b) Compute the distance (20 points)
c) Display the line equation (25 points)
d) Find the closest point to the line in c)(35 points)
e) Exit

The program will finalize ONLY when option e) is chosen. (5 points)

Deliverables

You will turn in two files, a C source code file, and text file with an example of the program output and any special instruction to run your program.

The C source code file should:

1) Comply with all of the formatting requirements already discussed.
2) Query the user(input)
3) Display the output
4) Perform the operations described.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Cs1325- write a program to find distance between the two
Reference No:- TGS02218719

Now Priced at $45 (50% Discount)

Recommended (97%)

Rated (4.9/5)