write a c-program to display the time using FOR loop
Answers were Sorted based on User's Feedback
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 |
Answer / guru
sir, actually i want same program but not using for loop,
using goto statement
Is This Answer Correct ? | 1 Yes | 2 No |
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 |
main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }
Find your day from your DOB?
15 Answers Accenture, Microsoft,
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
how can i cast a char type array to an int type array
main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }
main() { extern int i; i=20; printf("%d",i); }
#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..?
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().
plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............
how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.
0 Answers Mbarara University of Science and Technology,
main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }