Created
September 30, 2013 21:22
-
-
Save somratcste/6770478 to your computer and use it in GitHub Desktop.
Two points such as (x1,y1) and (x2,y2) for how we can find the straight line equation such type of program are described here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int p[2],q[2],x,i,j,k; | |
float m,y; | |
printf("Enter your two points : \n"); | |
for(i=1;i<=2;i++) | |
{ | |
printf("x[%d] : ",i); | |
scanf("%d", &p[i]); | |
printf("y[%d] : ",i); | |
scanf("%d", &q[i]); | |
} | |
printf("Your putting two value are : \n\n"); | |
for(i=1;i<=2;i++) | |
printf("x[%d] : %d \t y[%d] : %d\n",i,p[i],i,q[i]); | |
j=q[2]-q[1]; | |
k=p[2]-p[1]; | |
m=j/k; | |
y=q[1]-m*p[1]; | |
if(j==k) | |
{ | |
j=k=1; | |
printf("\n\nYour equation are : \n"); | |
printf("\t\ty=%dx+%.1f\n\n",j,y); | |
} | |
else | |
{ | |
printf("\n\nYour equation are : \n"); | |
printf("\t\ty=%d/%dx+%.1f\n\n",j,k,y); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment