By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,516 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,516 IT Pros & Developers. It's quick & easy.

source code of NESTED for LOOP to show digital clock on screen....

P: 8
hey...wanna source code of...digital clock by using nested for loop..if anybody know plzzzzzzzzzz...help me...i m getting eror in it..not sure wt do ....:(
Sep 23 '06 #1
Share this Question
Share on Google+
5 Replies


Banfa
Expert Mod 5K+
P: 8,916
If you are "getting an error in it" then perhaps you should have posted "it" and the error that you are getting.
Sep 23 '06 #2

P: 8
If you are "getting an error in it" then perhaps you should have posted "it" and the error that you are getting.
source code is...
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main(void)
{
int i,j,k;
gotoxy(40,12);
for(i=1;i<=12;i++)
{
for(j=0;j<=59;j++)
{
delay(90);
for(k=0;k<=59;k++)
clrscr();
printf("%d:%d:%d",i,j,k);
delay(90);
}
}
getch();


actually i want output as same as that of digital clock i.e..
1:1:00...after 59 sec ..sec converted into 00 but it doesnt....
should i use..%f instead of %d????
plzz..reply me fast because its my assignment....
iwll b very thankful to u..
Sep 27 '06 #3

100+
P: 293
D_C
You are saying you want it to print "01:00:00" at exactly 1PM, yet it prints "1:0:0"?
I'm not printf() expert, but I think you could do printf(%2d ... ,k). In C++, iomanip.h has setfill('0') and setwidth(2). However, I think C just has printf.
Sep 27 '06 #4

P: 1
@biltz
this program gives fatal error in conio.h how should i solve
Oct 9 '16 #5

Oralloy
Expert 100+
P: 983
Hey blitz,

Are you trying to use a real clock value, from your system, or are you just faking it with the three nested loops?

Kind Regards,
Oralloy
Oct 9 '16 #6

Post your reply

Sign in to post your reply or Sign up for a free account.