Index: Topic & Date
Index: Topic & Date
Teacher’s
S.No Topic & Date Signature
1
PROGRAM - I
Program:
#include <stdio.h>
#include <graphics.h>
void dda_algorithm(int dx, int dy, int x1, int x2, int y1, int y2, int
x, int y, int delay_time);
int main()
{
int gd = DETECT, gm;
int delay_time, x, y, dx, dy;
int x1, y1, x2, y2;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
printf("\nEnter Initial Line Coordinates:\n");
printf("\nEnter the value of x1:\t");
scanf("%d", &x1);
printf("\nEnter the value of y1:\t");
scanf("%d", &y1);
printf("\nEnter Final Line Coordinates:\n");
printf("\nEnter the value of x2:\t");
scanf("%d", &x2);
printf("\nEnter the value of y2:\t");
scanf("%d", &y2);
printf("\nEnter delay time:\t");
scanf("%d", &delay_time);
dda_algorithm(dx, dy, x1, x2, y1, y2, x, y, delay_time);
return 0;
}
2
void dda_algorithm(int dx, int dy, int x1, int x2, int y1, int y2, int
x, int y, int delay_time)
{
int count = 1;
int increment;
dx = abs(x2 - x1);
dy = abs(y2 - y1);
if(dx >= dy)
{
increment = dx;
}
else
{
increment = dy;
}
dx = dx / increment;
dy = dy / increment;
x = x1;
y = y1;
for(count = 1; count <= increment; count++)
{
putpixel(x, y, 4);
x = x + dx;
y = y + dy;
delay(delay_time);
}
closegraph();
}
3
Program I
Output
4
PROGRAM - II
Program:
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
void main()
{
int gd=DETECT,gm;
int s;
char *lname[]={"SOLID LINE","DOTTED LINE","CENTER LINE",
"DASHED LINE","USERBIT LINE"};
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
clrscr();
cleardevice();
printf("Line styles:");
for (s=0;s<5;s++)
{
setlinestyle(s,1,3);
line(100,30+s*50,250,250+s*50);
outtextxy(255,250+s*50,lname[s]);
}
getch();
closegraph();
}
5
Program II
Output
6
PROGRAM - III
Program:
#include <graphics.h>
#include<stdio.h>
#include <conio.h>
int main()
{
//initilizing graphic driver and
//graphic mode variable
int gd=DETECT,gm;
7
//using fill ellipse and ellipse for creating face.
fillellipse(310, 85, 2, 6);
fillellipse(290, 85, 2, 6);
getch();
return 0;
}
8
Program III
Output
9
PROGRAM - IV
Program:
#include <graphics.h>
#include <conio.h>
#include<stdio.h>
#include<dos.h>
main()
{
int i, j = 0, gd = DETECT, gm;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(25,240,"Press any key to view the moving car");
getch();
setviewport(0,0,639,440,1);
getch();
closegraph();
return 0;
}
10
Program IV
Output 1
OUTPUT 2
11
PROGRAM - V
Program:
#include <stdio.h>
#include <dos.h>
#include <graphics.h>
12
x++;
// driver function
int main()
{
int xc = 50, yc = 50, r2 = 30;
int gd = DETECT, gm;
initgraph(&gd, &gm, ""); // initialize graph
circleBres(xc, yc, r); // function call
return 0;
}
13
Program V
Output
14