#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void
main()
{
float
m,x1,y1,x2,y2;
int
x,y;
int
gdriver=DETECT,gmode,gerror;
clrscr();
printf("
PROGRAM FOR THE LINE INTERCEPT \n");
printf("
Enter the value of x1");
scanf("%f",&x1);
printf("
Enter the value of y1");
scanf("%f",&y1);
printf("
Enter the value of x2");
scanf("%f",&x2);
printf("
Enter the value of y2");
scanf("%f",&y2);
initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi");
m=(y2-y1)/(x2-x1);
for(x=1;x<=x2;x++)
{
y=m*(x-x1)+y1;
putpixel(x,y,15);
delay(50);
}
getch();
closegraph();
}
good program but not working for horizontal and vertical line.
ReplyDeleteOutput?
ReplyDeleteEnter the first line value 2 3
ReplyDeleteEnter the second line value 3 2
Output Kya h iska
ReplyDelete