8. Admission no.: 14S121
Page 7
y++;
if(current==0 && c==10)
{
current=1;c=-1;
}
if(current==1 && c==6)
{
current=0;c=-1;
}
c++;
}
}
}
void main()
{
float x1,x2,y1,y2;
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm, "C:TCbgi");
printf("enter end point of line x1 t");
scanf("%f",&x1);
printf("enter end point of line y1 t");
scanf("%f",&y1);
printf("enter end point of line x2 t");
scanf("%f",&x2);
printf("enter end point of line y2 t");
scanf("%f",&y2);
bress(x1,y1,x2,y2);
12. Admission no.: 14S121
Page 11
Program 4: WAP in C Implement A Rotation.
# include <stdio.h>
# include <conio.h>
# include <graphics.h>
# include <math.h>
void main()
{
int x1,y1,x2,y2,gd=DETECT,gm,t;
clrscr();
initgraph(&gd,&gm,"C:TCBGI");
printf("nEnter the co-ordinates of first point : ");
scanf("%d %d",&x1,&y1);
printf("nEnter the co-ordinates of second point : ");
scanf("%d %d",&x2,&y2);
printf("nEnter rotational angle t: ");
scanf("%d",&t);
printf("nInitial line is:");
line(x1,y1,x2,y2);
x2=x2*(cos(t))-y2*(sin(t));
y2=x2*(sin(t))+y2*(cos(t));
printf("nRotated line is: ");
line(x1,y1,x2,y2);
getch();
closegraph();
}
14. Admission no.: 14S121
Page 13
Program 5: WAP in C Implement A Translation.
# include <stdio.h>
# include <conio.h>
# include <graphics.h>
void main()
{
int x1,y1,x2,y2,gd=DETECT,gm,tx,ty;
clrscr();
initgraph(&gd,&gm,"C:TCBGI");
printf("nEnter the co-ordinates of first point : ");
scanf("%d %d",&x1,&y1);
printf("nEnter the co-ordinates of second point : ");
scanf("%d %d",&x2,&y2);
printf("nEnter translational index tx and ty: ");
scanf("%d%d",&tx,&ty);
printf("nInitial line is:");
line(x1,y1,x2,y2);
x1=x1+tx;
y1=y1+ty;
x2=x2+tx;
y2=y2+ty;
printf("nTranslated line is: ");
line(x1,y1,x2,y2);
getch();
closegraph();
}