The Philippine Electronics and Technology Forum
February 10, 2012, 12:59:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: 1 [2]   Go Down
  Print  
Author Topic: digital clock program in turbo C..pls help :(  (Read 2018 times)
mini_mouse ^_^
Size C Battery
*****

Pogi/Ganda Points: 4
Offline Offline

Gender: Female
Posts: 187


...All is Well...


« Reply #20 on: March 15, 2010, 02:59:38 PM »


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main(){

int hh, mm, sec;

for(hh=0;h<=12;hh++)
{

for(mm=0;min<60;min++)
{

for(sec=0;sec<60;sec++)
{
SYSTEM("cls");
printf("%d:%d:%d", hh, min, sec)
delay(60);
}

}
}

getche();
return 0;
}

hehehe, edited ko na...


Logged

...I'm thankful each and every day, coz I found you...
The Philippine Electronics and Technology Forum
« Reply #20 on: March 15, 2010, 02:59:38 PM »

 Logged
akhen
Diesel Generator
*

Pogi/Ganda Points: 41
Offline Offline

Gender: Female
Posts: 1080


"Learning is good but application is 100x better!"


« Reply #21 on: March 15, 2010, 05:08:55 PM »

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main(){

int hh, mm, sec;

for(hh=0;h<=12;hh++)
{

for(mm=0;min<60;min++)
{

for(sec=0;sec<60;sec++)
{
SYSTEM("cls");
printf("%d:%d:%d", hh, min, sec)
delay(60);
}

}
}

getche();
return 0;
}

hehehe, edited ko na...

possible bugs:

Code:
for(hh=0;h<=12;hh++)

Code:
for(mm=0;min<60;min++)
Logged

zeitcheist
Size AA Battery
****

Pogi/Ganda Points: 2
Offline Offline

Gender: Male
Posts: 114



« Reply #22 on: March 15, 2010, 10:09:57 PM »

hindi pansinin, pero ire-report yan ng compiler kung isa lang sa dalawang var ang declared.. hehe.. ^^
Logged

There are only 10 types of people in the world;
those who understand binary, and those who don't.
razor2300
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 2


« Reply #23 on: March 22, 2010, 03:41:52 AM »

Patulong po, eto po ung nagawa ko out of all the info na nakuha ko dito, i'm using Turbo C++

it works fine but the problem is... ung clock ng stop sa 11:60:60

which is equivalent to 12 hrs and 1 min..

how can i make it na mag stop kapag 12:00:00 sakto?

please help me out...i'm totally out of myself >.< thanks a lot..



#include<iostream.h>
#include<conio.h>
#include<dos.h>

main()
{
clrscr();
int sec,min,hr;

for(hr=0;hr<=24;hr++)
{
if (hr==12)
break;
for(min=0;min<=60;min++)
{
for(sec=0;sec<=60;sec++)
{

clrscr();
cout<<"\n\t\t\tThe time will stop at 12:00:00\n";
cout<<"\n\t\t     ====================================";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #  \t  HH : MM : SS \t        #";
cout<<"\n\t\t     #  \t  "<<hr<<" : "<<min<<" : "<<sec<<" \t\t#";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     ====================================";
cout<<"\n\n\t\t\tPress a key to stop temporarily";
}
}
}

delay(0);
getch();
return 0;
}
Logged
razor2300
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 2


« Reply #24 on: March 22, 2010, 04:20:01 PM »

the problem is solved.. here's the new code...

#include<iostream.h>
#include<conio.h>
#include<dos.h>

main()
{
clrscr();
int sec,min,hr;

for(hr=11;hr<=24;hr++)
{
if (hr==12)
{
sec=00;
min=00;
gotoxy(4,5);
cout<<"\n\t\t     #  \t  HH : MM : SS \t        #";
gotoxy(4,6);
cout<<"\n\t\t     #  \t  "<<hr<<" : "<<min<<" : "<<sec<<" \t\t#";
break;
}
for(min=00;min<60;min++)
{
for(sec=00;sec<60;sec++)
{
gotoxy(4,5);
cout<<"\n\t\t     #  \t  HH : MM : SS \t        #";
gotoxy(4,6);
cout<<"\n\t\t     #  \t  "<<hr<<" : "<<min<<" : "<<sec<<" \t\t#";
delay(10);
clrscr();
cout<<"\n\t\t\tThe time will stop at 12:00:00\n";
cout<<"\n\t\t     ====================================";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     #        \t\t\t        #";
cout<<"\n\t\t     ====================================";
cout<<"\n\n\t\t\tPress a key to stop temporarily";
}
}
}
getch();
return 0;
}



the only thing that is missing is when you press a key to stop temporarily, it didn't pause.. :] please help me to know how to do it.. thanks...
Logged
zeitcheist
Size AA Battery
****

Pogi/Ganda Points: 2
Offline Offline

Gender: Male
Posts: 114



« Reply #25 on: March 22, 2010, 11:13:55 PM »

kbhit() kasi gagamitin mu para malaman kung may pressed key..

Saka mali yang initialization mu sa outermost loop : for(hr=11;hr<=24;hr++)
Di ba ang habol mu eh start at 00? Start yan sa 11.. Saka bakit 24 pa eh break k rin nmn after 12?

Hmm, ayusin mu muna yan.. Kelan mu ba to need?
Logged

There are only 10 types of people in the world;
those who understand binary, and those who don't.
The Philippine Electronics and Technology Forum
   

 Logged
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Digital alarm clock « 1 2 »
Analog and Mixed Signal Device Repair (Electronics Technician Forum)
ahlburuto 35 3917 Last post June 06, 2008, 03:22:24 PM
by mArKhAo
HELP: clock program
General Electronics and Technology Discussion
balingkit08 1 402 Last post September 02, 2010, 11:16:05 AM
by dimps
DIGITAL CLOCK « 1 2 »
General Digital Design
elydjah 23 4893 Last post March 11, 2011, 02:38:41 PM
by ultrasonic™
digital alarm clock « 1 2 »
General Digital Design
hajimeh 31 3389 Last post January 04, 2012, 05:51:39 PM
by Maximus IX
shot clock program using c++ tulong!!!
COE Students
neon11 1 536 Last post March 08, 2010, 11:13:36 AM
by mini_mouse ^_^
The digital clock
General Digital Design
billjunes 3 474 Last post February 28, 2010, 10:16:14 AM
by marcelino
pa2long naman po gumawa ng program naung clock
PIC Microcontrollers
sonic05 18 446 Last post October 03, 2010, 11:05:38 AM
by sonic05
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!