Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions PROGRAM1.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main(){
int gd=DETECT,gm,x1,x2,y1,y2,x3,y3,x4,y4;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
printf("Enter the line coordinates");
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
line(x1,y1,x2,y2);

printf("enter the additional coordinates");
scanf("%d %d %d %d",&x3,&y3,&x4,&y4);

setcolor(RED);
line(x1+x3,y1+y3,x2+x4,y2+y4);
getch();
closegraph();
}
33 changes: 33 additions & 0 deletions PROGRAM3.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
void draw_line(int,int,int,int);
void main(){
int x1,x2,y1,y2,gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
draw_line(x1,y1,x2,y2);
getch();
closegraph();
}
void draw_line(int x1,int y1,int x2,int y2){
int dx,dy,steps,i,x,y;
dx=x2-x1;
dy=y2-y1;
if(dx>=dy)steps=dx;
else steps=dy;
x=x1;
y=y1;
i=1;
dx=dx/steps;
dy=dy/steps;
while(i<=steps){
putpixel(x,y,WHITE);
x=x+dx;
y=y+dy;
i++;

}


}
Binary file added output_1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output_3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.