#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<iostream.h>
int calculatehrs(int h)
{
int x;
switch(h)
{
case 0: x=90;
break;
case 1:
case 13: x=60;
break;
case 2:
case 14: x=30;
break;
case 3:
case 15: x=0;
break;
case 4:
case 16: x=330;
break;
case 5:
case 17: x=300;
break;
case 6:
case 18: x=270;
break;
case 7:
case 19: x=240;
break;
case 8:
case 20: x=210;
break;
case 9:
case 21: x=180;
break;
case 10:
case 22: x=150;
break;
case 11:
case 23: x=120;
break;
case 12:
case 24: x=90;
break;
}
return(x);
}
int calculatemin(int m)
{
int x;
if(m%5==0)
{
switch(m)
{
case 0: x=90;
break;
case 5: x=60;
break;
case 10: x=30;
break;
case 15: x=360;
break;
case 20: x=330;
break;
case 25: x=300;
break;
case 30: x=270;
break;
case 35: x=240;
break;
case 40: x=210;
break;
case 45: x=180;
break;
case 50: x=150;
break;
case 55: x=120;
break;
case 60: x=90;
break;
}
}
else
{
if(m>0&&m<15)
{
switch(m)
{
case 1: x=84;
break;
case 2: x=78;
break;
case 3: x=72;
break;
case 4: x=66;
break;
case 6: x=54;
break;
case 7: x=48;
break;
case 8: x=42;
break;
case 9: x=36;
break;
case 11: x=24;
break;
case 12: x=18;
break;
case 13: x=12;
break;
case 14: x=6;
break;
}
}
if(m>15&&m<30)
{
switch(m)
{
case 16: x=354;
break;
case 17: x=348;
break;
case 18: x=342;
break;
case 19: x=336;
break;
case 21: x=324;
break;
case 22: x=318;
break;
case 23: x=312;
break;
case 24: x=306;
break;
case 26: x=294;
break;
case 27: x=288;
break;
case 28: x=282;
break;
case 29: x=276;
break;
}
}
if(m>30&&m<45)
{
switch(m)
{
case 31: x=264;
break;
case 32: x=258;
break;
case 33: x=252;
break;
case 34: x=246;
break;
case 36: x=234;
break;
case 37: x=228;
break;
case 38: x=222;
break;
case 39: x=216;
break;
case 41: x=204;
break;
case 42: x=198;
break;
case 43: x=192;
break;
case 44: x=186;
break;
}
}
if(m>45&&m<60)
{
switch(m)
{
case 46: x=174;
break;
case 47: x=168;
break;
case 48: x=162;
break;
case 49: x=156;
break;
case 51: x=144;
break;
case 52: x=138;
break;
case 53: x=132;
break;
case 54: x=126;
break;
case 56: x=114;
break;
case 57: x=108;
break;
case 58: x=102;
break;
case 59: x=96;
break;
}
}
}
return(x);
}
int changehrs(int m,int a)
{
if(m>15&&m<=30)
a-=12;
if(m>30&&m<=45)
a-=18;
if(m>45&&m<60)
a-=24;
return (a);
}
void main()
{
int gdriver=DETECT,gmode,h,m,s,a,b,c;
initgraph(&gdriver,&gmode,”c:\tc\bgi”);
struct time t;
gettime(&t);
h=t.ti_hour;
m=t.ti_min;
s=t.ti_sec;
a=calculatehrs(h);
b=calculatemin(m);
c=calculatemin(s);
a=changehrs(m,a);
for(int i=a;i>0;i-=6)
for(int j=b;j>0;j-=6)
for(int k=c;k>0;k-=6)
{
setbkcolor(7);
settextstyle(1,HORIZ_DIR,5);
setcolor(BLUE);
outtextxy(190,20,”Analog Clock”);
settextstyle(8,HORIZ_DIR,2);
setcolor(BLUE);
circle(300,200,102);
setcolor(YELLOW);
circle(300,200,100);
outtextxy(385,185,”3″);
outtextxy(288,98,”12″);
outtextxy(207,185,”9″);
outtextxy(295,270,”6″);
circle(345,123,2);
circle(378,155,2);
circle(378,245,2);
circle(345,280,2);
circle(253,278,2);
circle(223,245,2);
circle(223,155,2);
circle(253,123,2);
setcolor(RED);
pieslice(300,200,i-1,i,75);
setcolor(WHITE);
pieslice(300,200,j-1,j,85);
setcolor(BLUE);
pieslice(300,200,k-1,k,95);
setcolor(RED);
settextstyle(3,HORIZ_DIR,1);
outtextxy(360,400,”Press any key to exit…!!”);
sleep(1);
clearviewport();
if(i==6)
a=360;
if(j==6)
b=360;
if(k==6)
c=360;
if(kbhit())
{
setcolor(YELLOW);
setbkcolor(BLUE);
settextstyle(1,HORIZ_DIR,8);
outtextxy(130,150,”Thank You”);
sleep(3);
exit(0);
}
}
}
Please apply your code for Linux environment too … I don't use windows
i want shopping mall management system project
Login()
Add/Remove/UpdateUser()
UserPanel()
AdminPanel
Add/Remove/UpdateProduct()
Add/Remove/UpdateOrder()
CheckTotalSale()
ShowAllProducts()
ShowSpecificDaySale
ShowProfit/Lose()
…2 more()
I will soon write a program for that and publish it. Just keep visiting. 🙂
When I running this program I noticed that I have 1 error so this is a message error:
"fatal ..INCLUDEIOSTREAM.H 19:Error directive: Must use for the type iostream."
I hope for you to tell how can I fix this problem
thanks
You can try
#include
Use #include
Save as your file with .cpp
amo baghdad either remove that line or save your program with .cpp extension because iostream.h is used in c++ program
Neeraj if ur intrstd i would like to wrk wid u on nirma's project wid addtnl features
Hi. Can u Help me for making my project on Analog Clock. Plz cntct me. Syedubii@gmail.com
Microsoft visual c++ gives me this error if i try running it
'#include ': skipped when looking for precompiled header use
'#include ': skipped when looking for precompiled header us
'#include ': skipped when looking for precompiled header use
'#include ': skipped when looking for precompiled header use
Hei Neeraj Mishra , thank you very much for your effort. I am really enjoying your blog. If it possible can elso write some explanation to your programs for a beginners.
Did you get the outputs when compiling it??
how do i do this? where do i enter the copied text?
hey umm im a budding programmer and i would like to know what header file you used cause im using dev-cpp?
Hey hw to do c graphics prog n mouse interfacing on linux environment?
Can you please explain how you have executed it .. ?? the logic behind it ….
how to download it as cpp or how to convert it into cpp??
Just copy the whole program and then paste it into notepad. Now save the this file as .cpp extension, for example "demo.cpp".
give me this error when i running my program
BGI graphics not supported under window
how can i fix this problem
Actually BGI graphics works in old compiler like turbo C++. It will not work in modern compilers. Which compiler you are using?
Turbo c win_4.5
Then the program must work. Just change the path “c:\tc\bgi” with the path of bgi folder of your compiler.
When ii am executing this it’s showing “Graphics Not Initialised ”
What can i do to correct it?????
Not working on Visual 2015
when I running the program only one error is obtain after void main(). that is” declaration syntax error”
what can I do?
can u write code for analog clock without using graphics
There are no error but there are no out put plz tell the and??
You have to copy two bgi file from folder turboc /bgi folder to bin folder.the file names are:
Egavga.bgi
Cga.bgi
There is no error in my program but the programming is not running. Plz tell me ans ???
Whenever i run it it says:
BGI error: graphics not initialized (use ‘initgraph’)
i run it code it succesful but, output not show
Hello i run it and but here
….second hand not working properly ……there is delay of 6 second in 1 shift of 6 degree clock ……what can i do?
i run and compile it successful, but output not shown. don’t understand why.
Hai sir!
Can you tell me some books that will help me in c++ coding with line by line explanations.
Iam a beginner sir.
Please help me out.
It giving me syantax error after switch statement
The code is running without any error but not displaying anything…
Do help
same problems
Don’t run it in windows, It is probably Linux or Unix based code. But I believe after certain “tweaks”, the code could be made to run on windows.
NO Offence Mate, but that is the most incompetent and IDIOTIC way to assign a value to a variable upon a certain condition, when there is obviously a pattern in the values of “x”.
For example in the calculatemin() func, rather than the extensive use of switch-case for every possible value of m, couldn’t you have used simple mathematical expression, viz:
int calculatemin(int m){
int x;
if(m>=15 && m<=60){
x=360-6*(m-15);
}
if(m=0){
x= 90-6*m;
}
return x;
}
Seriously Bro! Your code for the rest of the thing quite good, but the function is terribly horrible and quite vexing to even see.
Regards
Kudo Shinichi
correction the Second “if”:
else if(m>=0 && m<15)
{x=90-6*m}