Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program to draw a slope of line

#include<graphics.h>
#include<stdio.h>
#include<conio.h>
 Void main ( )
{
 int gdriver=DETECT,gmode,x,y,x1,y1,x2,y2,xend;
float m, b, xinc, yinc, dx, dy;
clrscr( );
initgraph(“&gd,&gm”,“ ”);
printf("Enter the starting point and ending point:-");
scanf("%d%d%d%d",&x1,&x2,&y1,&y2);
dx=x2-x1;
dy=y2-y1;
m=dx/dy
b=y1-m*x1
          
if(dx<0)
             
{
         x=x2;
                     
y=y2;
                     
xend=x1;
      }
           
else
             
{
          x=x1;
                        
y=y1;
                        
xend=x2;
      }
loop1:
          if(x>xend)
           goto  loop:
        putpixel(x,y,green):
              x++;
        y=m*x+b:
            goto loop1;
             loop:
                 
getch( );
closegraph( );
}

Previous
Next Post »