C Program for Drawing a Straight Line using Standard Library Function :
# include <stdio.h>
# include <conio.h>
# include <graphics.h>
void main()
{
int x1,y1,x2,y2;
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
clrscr();
printf("\n\n\tEnter the co-ordinates of 1st point : ");
scanf("%d %d",&x1,&y1);
printf("\n\n\tEnter the co-ordinates of 2nd point : ");
scanf("%d %d",&x2,&y2);
line(x1,y1,x2,y2);
getch();
closegraph();
}
Output
# include <stdio.h>
# include <conio.h>
# include <graphics.h>
void main()
{
int x1,y1,x2,y2;
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
clrscr();
printf("\n\n\tEnter the co-ordinates of 1st point : ");
scanf("%d %d",&x1,&y1);
printf("\n\n\tEnter the co-ordinates of 2nd point : ");
scanf("%d %d",&x2,&y2);
line(x1,y1,x2,y2);
getch();
closegraph();
}
Output
No comments:
Post a Comment