Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  guihiy
Language: C/C++
Code:
#include <stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
     int gd=DETECT,gm;
     int x1,y1,x2,y2,dx,dy,steps,k;
     float xincrement,yincrement,x,y;
     initgraph(&gd,&gm,"c:\\TC\\BGI");
     printf("enter the starting point of x axis");
     scanf("%d",&x1);
     printf("enter the end point of x axis");
     scanf("%d",&x2);
     printf("enter the starting point bof y axis");
     scanf("%d",&y1);
     printf("enter the end point of y axis");
     scanf("%d",&y2);
     dx=x2-x1;
     dy=y2-y1;
     x=x1;
     y=y1;
     if(abs(dx)>abs(dy))
     steps=abs(dx);
     else
     steps=abs(dy);
     xincrement=dx/(float)steps;
     yincrement=dy/(float)steps;
     putpixel(ceil(x),ceil(y),WHITE);
     for(k=1;k<=steps;k++)
     {
          x=x+xincrement;
          y=y=yincrement;
          putpixel(ceil(x),ceil(y),WHITE);
     }
     closegraph();
}
     




          
Comments: