/*CSEMATTER.BLOGSPOT.IN
PROGRAM NAME-PROGRAM TO DRAW A LINE USING SLOPE*/
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
{int gd=DETECT,gm;
float x1,x2,y1,y2;
float m,c,x,y,i;
printf("enter the first coordinatse");
scanf("%f %f",&x1,&y1);
printf("enter the second coordinatse");
scanf("%f %f",&x2,&y2);
m=(y2-y1)/(x2-x1);
c=y1-(m*x1);
initgraph(&gd,&gm,"C:\tc\bgi");
if(x2!=x1)
{ x=x1;
y=y1;
while(x<=x2)
{y=(m*x)+c;
putpixel(x,y,15);
x++;}
}
else
printf("ERROR!!!!!!");
getch();
closegraph();}
No comments:
Post a Comment