IMPLEMENTATION OF BRESENHAM LINE DRAWING ALGORITHM USING C++
IMPLEMENTATION OF BRESENHAM LINE DRAWING ALGORITHM USING C++ CODE: #include<stdio.h> #include<graphics.h> void drawline(int,int,int,int); int abs(int n){ return n<0?-n:n; } void swap(int *a, int *b){ *a = (*a+*b) - (*b=*a); } int main(){ int x1, x2, y1, y2; printf("Enter the first point "); scanf("%d%d",&x1,&y1); printf("Enter the second point "); scanf("%d%d",&x2,&y2); int gd=DETECT, gm; initgraph(&gd,&gm,NULL); drawline(x1,y1,x2,y2); getch(); closegraph(); } void drawline(int x1, int y1, int x2, int y2) { int dx, dy, p, xs, ys, xe, ye, x, y; dx=x2-x1; dy=y2-y1; p=2*dy-dx; if(abs(dx)>=abs(dy)){ if(dx>=0){ x = xs = x1, y = ys = y1, xe...