Skip to content

Commit cb300cb

Browse files
authored
Add files via upload
1 parent 171d2c7 commit cb300cb

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

CIRCLE.C

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <graphics.h>
2+
#include <stdlib.h>
3+
#include <stdio.h>
4+
#include <conio.h>
5+
6+
int main(void)
7+
{
8+
/* request auto detection */
9+
int gdriver = DETECT, gmode, errorcode;
10+
int midx, midy;
11+
int radius = 100;
12+
13+
/* initialize graphics and local variables */
14+
initgraph(&gdriver, &gmode, "C:\\turboc3\\bgi");
15+
16+
/* read result of initialization */
17+
errorcode = graphresult();
18+
if (errorcode != grOk) /* an error occurred */
19+
{
20+
printf("Graphics error: %s\n", grapherrormsg(errorcode));
21+
printf("Press any key to halt:");
22+
getch();
23+
exit(1); /* terminate with an error code */
24+
}
25+
26+
midx = getmaxx() / 2;
27+
midy = getmaxy() / 2;
28+
setcolor(getmaxcolor());
29+
30+
/* draw the circle */
31+
circle(midx, midy, radius);
32+
33+
/* clean up */
34+
getch();
35+
closegraph();
36+
return 0;
37+
}

CLOCK.C

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#include<conio.h>
2+
#include<graphics.h>
3+
#include<math.h>
4+
#include<dos.h>
5+
6+
#define WBC 5
7+
//^watchbackcolor
8+
#define X 200
9+
#define Y 200
10+
11+
void dial(int x, int y);
12+
void sechand(int timeminute);
13+
14+
void minhand(int t)
15+
{
16+
int x1,y1;
17+
setlinestyle(0,0,3);
18+
19+
x1= X+ (80 * cos(t*0.1047));
20+
y1= Y+ (80 * sin(t*0.1047));
21+
22+
setcolor(BLACK);
23+
line( X, Y, x1, y1);
24+
25+
setcolor(WBC+1);
26+
line( X, Y, X+ 80 * cos((t-1)*0.1047),Y+ 80 * sin((t-1)*0.1047));
27+
circle(X,Y,4);
28+
}
29+
30+
void sechand(int t)
31+
{
32+
int x1,y1;
33+
setlinestyle(0,0,3);
34+
35+
x1= X+(100 * cos(t*0.1047));
36+
y1= Y+(100 * sin(t*0.1047));
37+
38+
setcolor(RED);
39+
line(X, Y, x1, y1);
40+
41+
setcolor(WBC+1);
42+
line(X, Y, X+ 100 * cos((t-1)*0.1047),Y+ 100 * sin((t-1)*0.1047));
43+
44+
circle(X,Y,4);
45+
}
46+
47+
void dial(int x,int y)
48+
{
49+
int const size=200;
50+
51+
setfillstyle(1,WBC);
52+
fillellipse(x,y,size,size);
53+
54+
setfillstyle(1,WBC+1);
55+
fillellipse(x,y,size-20,size-20);
56+
57+
outtextxy(x,y-(size-40),"12");
58+
outtextxy(x,y+(size-40),"6");
59+
outtextxy(x+(size-40),y,"3");
60+
outtextxy(x-(size-40),y,"9");
61+
outtextxy(x+size/3,y-2*size/3,"1");
62+
outtextxy(x+2*size/3,y-size/3,"2");
63+
outtextxy(x+2*size/3,y+size/3,"4");
64+
outtextxy(x+size/3,y+2*size/3,"5");
65+
outtextxy(x-size/3,y+2*size/3,"7");
66+
outtextxy(x-2*size/3,y+size/3,"8");
67+
outtextxy(x-size/3,y-2*size/3,"11");
68+
outtextxy(x-2*size/3,y-size/3,"10");
69+
70+
circle(x,y,4);
71+
}
72+
73+
void main()
74+
{
75+
int gd=DETECT, gm,i,j, flag=1;
76+
initgraph(&gd,&gm,"C:\\turboc3\\bgi");
77+
78+
dial(200,200);
79+
do
80+
{
81+
minhand(i);
82+
for(j=0;j<60;j++)
83+
{
84+
sechand(j);
85+
delay(1000
86+
);
87+
if(kbhit()) {
88+
flag =0;
89+
break;
90+
}
91+
}
92+
i++;
93+
}while(flag);
94+
closegraph();
95+
}

0 commit comments

Comments
 (0)