Question: In C language - Create main with an array of 5 points, reads in 4 points from the user by calling getLabel() 4 times. -
In C language
- Create main with an array of 5 points, reads in 4 points from the user by calling getLabel() 4 times.
- Display the gap or distance between the 1st and 2nd points, and 3rd and 4th points using function gap.
- Display the slope of the line between the 1st and 2nd points, and the 3rd and 4th points using function slope.
- Create a 5th point by calling perpLabel() using 1st and 2nd points.
Code is provided below
#include
struct mark_struct { double xaxis; double yaxis; char tag[25]; }; typedef struct mark_struct Point;
Point getLabel(); // get a point from the user(stdin)
double gap(Point mk1, Point mk2); // returns the distance between mk1 and mk2
double slope(Point mk1, Point mk2); /* finds slope of the line at mk1 going to mk2 */
void perpLabel (Point mk1, Point mk2, Point *mk3); /* calculate mk3 such that a line from mk1 to mk3 is perpendicular to the line from pt1 to mk2 */
int main() { Point aArray[5];
//finish main
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
