Skip to main content

Analog clock full code in cpp

Analog Clock code in turboc


Program :

#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm;
int x=320,y=240,r=200,i,h,m,s,thetamin,thetasec;
struct  time t;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
initgraph(&gd,&gm,"Akshay");
circle(x,y,210);
setcolor(4);
settextstyle(4,0,5);
for(i=0;i<12;i++)
{
if(i!=3)
outtextxy(x+(r-14)*cos(M_PI/6*i)-10,y-(r-14)*sin(M_PI/6*i)-26,n[i]);
else
outtextxy(x+(r-14)*cos(M_PI/6*i)-20,y-(r-14)*sin(M_PI/6*i)-26,n[i]);
}
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d",t.ti_hour, t.ti_min,t.ti_sec, t.ti_hund);
printf("\ncprogrammingbyakshay.blogspot.in");
while(!kbhit())
{
setcolor(5);
setfillstyle(1,5);
circle(x,y,10);
floodfill(x,y,5);
gettime(&t);
if(t.ti_min!=m)
{
setcolor(0);
line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180
)));
circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180))
,10);
line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h
-((m/2)*(M_PI/180))));
circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-(
(m/2)*(M_PI/180))),10);
}
if(t.ti_hour>12)
t.ti_hour=t.ti_hour-12;
if(t.ti_hour<4)
h=abs(t.ti_hour-3);
else
h=15-t.ti_hour;
m=t.ti_min;
if(t.ti_min<=15)
thetamin=(15-t.ti_min)*6;
else
thetamin=450-t.ti_min*6;
if(t.ti_sec<=15)
thetasec=(15-t.ti_sec)*6;
else
thetasec=450-t.ti_sec*6;
setcolor(4);
line(x,y,x+(r-110)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-110)*sin(M_PI/6*h
-((m/2)*(M_PI/180))));
circle(x+(r-130)*cos(M_PI/6*h-((m/2)*(M_PI/180))),y-(r-130)*sin(M_PI/6*h-(
(m/2)*(M_PI/180))),10);
line(x,y,x+(r-60)*cos(thetamin*(M_PI/180)),y-(r-60)*sin(thetamin*(M_PI/180
)));
circle(x+(r-80)*cos(thetamin*(M_PI/180)),y-(r-80)*sin(thetamin*(M_PI/180))
,10);
setcolor(15);
line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180
)));
delay(1000);
setcolor(0);
line(x,y,x+(r-70)*cos(thetasec*(M_PI/180)),y-(r-70)*sin(thetasec*(M_PI/180
)));
}
}

Comments

Popular posts from this blog

Minesweeper Game in C

Minesweeper Game in C language. This game is like a windows minesweeper game and I am giving you all the code for this game. You can easily understand the code if you are not a beginner. For beginners this code will quite hard to understand. Because in this code it contains mouse pointing function, graphics function, and so many other codes which makes it so hard to play and is a mind game. So play and enjoy it.   Click here for code Click for code

Make your own paint application in c and cpp

Paint application using simple turboc complier. Hello friends now make your own paint application or mini project in your simple c and cpp compiler. click to show the code for paint program

Bank Management System Project Using C Language

The source code for the Bank Management System for Customer Accounts is reasonably short and simple to comprehend. This C mini project is separated into many functions, most of which are connected to various financial operations. Some of the most critical functionalities are listed below to assist you better understand the project. menu()  – This function shows a menu or welcome screen that allows you to execute the various banking tasks listed below. new acc()  – Creates a new customer account using this function. It requests the customer's name, date of birth, citizenship number, address, and phone number, among other personal and financial information. You may pick from a variety of deposit accounts, including savings, current, fixed for 1 year, fixed for 2 years, and fixed for 3 years. view list()  – Displays a list of items. This feature allows you to access the customer's banking information, including the account number, name, address, and phone number supplied when the