0% found this document useful (0 votes)
20 views1 page

Solution To Question No.7: Program

This program takes in two coordinate points (x1, y1) and (x2, y2) as input and calculates the slope (m) and y-intercept (c) of the line passing through those points. It prints out the equation of that line in the form y=mx+c, or returns an error if the two points are the same.

Uploaded by

pontas97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Solution To Question No.7: Program

This program takes in two coordinate points (x1, y1) and (x2, y2) as input and calculates the slope (m) and y-intercept (c) of the line passing through those points. It prints out the equation of that line in the form y=mx+c, or returns an error if the two points are the same.

Uploaded by

pontas97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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();
}

You might also like