write a c-program to display the time using FOR loop

Answers were Sorted based on User's Feedback



write a c-program to display the time using FOR loop..

Answer / chaitanya

main()
{
for(;1;)
{
int hr,mt,sec;
for(hr=0;hr<24;hr++)
{
for(mt=0;mt<60;mt++)
{
for(sec=0;sec<60;sec++)
{
sleep(1000);
printf("%d:%d:%d",hr,mt,sec);
}
}
}
}
}

Is This Answer Correct ?    8 Yes 8 No

write a c-program to display the time using FOR loop..

Answer / guru

sir, actually i want same program but not using for loop,
using goto statement

Is This Answer Correct ?    1 Yes 2 No

write a c-program to display the time using FOR loop..

Answer / venugopal

main()
{
int hr,mt,sec;
for(hr=0;hr<12;hr++)
{
for(mt=0;mt<60;mt++)
{
for(sec=0;sec<60;sec++)
{
sleep(1000);
printf("%d:%d:%d",hr,mt,sec);
}
}
}/* here sleep(1000) maintain intervel of one sec b/w two
print statements*/ if u have any doubts contact my mail-id
is: venugopal.palavalasa@gmail.com

Is This Answer Correct ?    7 Yes 13 No

Post New Answer

More C Code Interview Questions

write a program in c to merge two array

2 Answers  


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

1 Answers  


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


C program to print magic square of order n where n > 3 and n is odd

2 Answers   Accenture,






void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. ā€“3, -1, 1, 3, 5

2 Answers   HCL,


void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(ā€œ%dā€,k); }

1 Answers  


main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }

1 Answers  


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


Categories