Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to read two points on a line, then two points on another line, a

ID: 3635136 • Letter: W

Question

Write a program to read two points on a line, then two points on another line, and determine whether the lines are parallel or whether they are intersect, and if they intersect, whether they are perpendicular. Two lines are parallel if their slopes are equal. Two lines are perpendicular if the product of their slopes is -1. You need to write a function, slope, that takes two points on the line and calculates their slope. Given two points, P1(x1, y1) and P2(x1, y2), the line's slope is: y2 - y1/x2 - x1 The program will continue to compare between the lines until a unique value is entered by the user to stop processing. Note: Using Loops and user defined functions is a must.

Explanation / Answer

#include<stdio.h>
float slope(float x,float y,float z,float l);
main()
{
float a,b,c,d,p,q,r,s,m,n;
printf("Enter the x,y coordinates of point one on line 1/n");
scanf("%f%f",&a&b);
printf("Enter the x,y coordinates of point two on line1 /n");
scanf("%f%f",&c&d);
m= slope(a,b,c,d);
printf("Enter the x,y coordinates of point one on line 2/n");
scanf("%f%f",&p,&q);
printf("Enter the x,y coordinates of point two on line 2 /n");
scanf("%f%f",&r,&s);
n=slope(p,q,r,s);
if(m==n)
printf("lines are parallel /n);
if(m*n==-1)
printf("lines are perpendicular);
float slope(float x,float y,float z,float l)
{
float m;
m= y-l/x-z;
return(m);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote