Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Programming Source Codes
C/C++ Source Codes
C# Source Codes
.........More

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
.........More

Tutorials
C Tutorial
C++ Tutorial
.........More

# C/C++ Source Codes

analog clock

/*PROGRAM TO CONSTRUCT THE CLOCK*/
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<math.h>
#define PI 3.14
#include<stdio.h>
void main()
{
int gd=DETECT,gm;
int h,m,s,xs,ys,xm,ym,xh,yh;
initgraph(&gd,&gm,"c:\\tc\\bgi");

struct time t;
fflush(stdout);
cleardevice();
setfillstyle(6,10);
circle(319,239,239);
circle(319,239,219);
floodfill(556,239,15);

setcolor(9);
settextstyle(1,0,4);
outtextxy(301,37,"12");
outtextxy(480,218," 3");
outtextxy(297,400," 6");
outtextxy(113,218," 9");

gettime(&t);
s=t.ti_sec;
h=t.ti_hour;
m=t.ti_min;
int ang=30;

for(int i=0;i<60;i++)
line(320+210*(cos(PI/180*(90-6*i))),240-210*(sin(PI/180*(90-6*i))),320+200*(cos(PI/180*(90-6*i))),240-200*(sin(PI/180*(90-6*i))));
settextstyle(4,0,3);
outtextxy(263,80,"Neeraj Gulia");

while(1)
{
if (kbhit())
exit(0);
gotoxy(36,25);
printf("%02d::%02d::%02d",h,m,s);
setcolor(4);
xs=320+150*(cos(PI/180*(90-6*s)));
ys=240-150*(sin(PI/180*(90-6*s)));
line(320,240,xs,ys);

setcolor(14);
xm=320+120*(cos(PI/180*(90-6*m)));
ym=240-120*(sin(PI/180*(90-6*m)));
setlinestyle(0,0,3);
line(320,240,xm,ym);

if(s>59)
{
s=0;
m++;
}
setcolor(5);
xh=320+90*(cos(PI/180*(90-ang*h)));
yh=240-90*(sin(PI/180*(90-ang*h)));
line(320,240,xh,yh);

if(m>59)
{
m=0;
h++;
s=0;

}
delay(980);
sound(40);
delay(50);
nosound();

setcolor(0);
line(320,240,xh,yh);
line(320,240,xm,ym);
setlinestyle(0,0,0);
line(320,240,xs,ys);
s++;
}
}