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

main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  


what is the code of the output of print the 10 fibonacci number series

2 Answers  


char *someFun1() { char temp[ ] = “string"; return temp; } char *someFun2() { char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’}; return temp; } int main() { puts(someFun1()); puts(someFun2()); }

2 Answers  


how to return a multiple value from a function?

2 Answers   Wipro,


Is the following code legal? struct a { int x; struct a b; }

1 Answers  






Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

1 Answers  


main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }

7 Answers  


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?

1 Answers   Wipro,


how to test pierrot divisor

0 Answers  


Categories