Sunteți pe pagina 1din 1

Solution to Question No.

7 :
Program:
/* Program to input two coordinate points in a 2-D plane and obtain the
equation of the line passing through them */
#include<stdio.h>
#include<math.h>
void main()
{
float x1,x2,y1,y2,m,c;
clrscr();
printf("Enter the first coordinate point(x1,y1):");
scanf("%f %f",&x1,&y1);
printf("Enter the second coordinate point(x2,y2):");
scanf("%f %f",&x2,&y2);
if (x1==x2 && y1==y2)
printf("Invalid input");
else
{ m=(y1-y2)/(x1-x2);
c=y1-m*x1;
printf("The equation of the required line is y=%fx+%f",m,c);
}
getch();
}

S-ar putea să vă placă și