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

a) Two points in a plane are specified using the coordinates(x1,y1) and (x2,y2).

ID: 3613367 • Letter: A

Question

a) Two points in a plane are specified using the coordinates(x1,y1) and (x2,y2). Write a program that calculates the slope of aline through two (non-vertical) points entered by the user. b) Write a program that accepts two points (see previousproblem) and determines the distance between them. a) Two points in a plane are specified using the coordinates(x1,y1) and (x2,y2). Write a program that calculates the slope of a line through two (non-vertical) points entered by the user. Slope=y2-y1/x2-x1 b) Write a program that accepts two points (see previousproblem) and determines the distance between them. Distance= root (x2-x1)^2+(y2-y1)^2

Explanation / Answer


int main()
{
double x1,y1,x2,y2,s=0,d;
cout<<"Enter x1,y1:";
cin>>x1>>y1;
cout<<"Enter x2,y2:";
cin>>x2>>y2;
if(x2!=x1)
s = (y2-y1)/(x2-x1);
d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
cout<<"Slope is :"<<s<<endl;
cout<<"Distance is :"<<d<<endl;
     system("pause");
}


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