You are on page 1of 3

#include<rahul.h>#include<iostream.

h>

void main()

char buffer[50];

int gdriver = DETECT, gmode, errorcode;

int xmax=getmaxx();

int ymax=getmaxy();

errorcode = graphresult();

if (errorcode != grOk)

printf("Graphics error: %s\n", grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

exit(1);

int x1,x2,y1,y2,dx, dy ,length,x,y,i,s1,s2;

clrscr();

scale();

cout<<"enter the value of x1";

cin>>x1;

cout<<"enter the value of x2";

cin>>x2;

cout<<"enter the value of y1";


cin>>y1;

cout<<"enter the value of x2";

cin>>y2;

dy=y2-y1;

if(x2>x1){

s1=1;

else if(x1>x2)

s1=-1;

else{

s1=0;

s2=1;

else if(y1>y2)

s2=-1;

else{

s2=0;

dx=(x2-x1)/length;

dy=(y2-y1)/length;

x=x1+0.5;

y=y1+0.5;

for(i=0;i<=length;i++)

{
x=x+dx;

y=y+dy;

putpixel(getmaxx()/2+x,getmaxy()/2-y,RED);

sprintf(buffer,"(%d,%d)",x1,y1);

puts(buffer);

outtextxy(getmaxx()/2+x1,getmaxy()/2-y1,buffer);

sprintf(buffer,"(%d,%d)",x2,y2);

puts(buffer);

outtextxy(getmaxx()/2+x2,getmaxy()/2-y2,buffer);

getch();

You might also like