Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  dsasdf
Language: C/C++
Code:
#include<graphics.h>
#include<iostream>
using namespace std;

int main()
{
     int gd=DETECT;
     int x1,x2,y1,y2,dx=0,dy=0,step=0,x=0,y=0;
     cout<<"Enter value for x1,x2,y1,y2:";
     cin>>x1;
     cin>>x2;
     cin>>y1;
     cin>>y2;
     
     int gm;
     initgraph(&gd,&gm,NULL);
     
     if(x2-x1>y2-y1)
     {
     step=(x2-x1);
     }
     else
     {
     step=(y2-y1);
     }
     dx=(x2-x1)/step;
     dy=(y2-y1)/step;
     x=x1;
     y=y1;
     while(step--)
     {
     putpixel(x,y,2);
     x=x+dx;
     y=y+dy;
     }
     
          
     getch();
     closegraph();
     return 0;
}
Comments: