I was making a digital clock in C programming. It takes input of current time from the user, then it updates the second to show the time in format HH:MM:SS.
I am confused with the part of for loop that is inside second.
for(i=0;i<8999990;i++)
i=i+1-1.
.
I have tried to dry run the code.
Suppose, I gave input 10:30:20 as hh:min:sec respectively.
Now, the for loop will start.
for loop for hr, then for loop for min, then for loop for sec...then for loop for i...
when sec is 20, for loop for i will run 89999990 times, and do i=i+1-1, ie update i value....
then sec will be 21....
what i am surprised of is how the "i" loop is creating an impact on the sec value?
and how that much fast?
[code]
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
int h=0,m=0,s=00;
double i;
printf("Enter time in format of HH MM SS\n");
scanf("%d%d%d",&h,&m,&s);
start:;
for(h;h<24;h++){
for(m;m<60;m++){
for(s;s<60;s++){
system("cls");
printf("\n\n\n\n\n\n\t\t\t\t\t\t%d:%d:%d\n",h,m,s);
for( i=0;i<89999900;i++){
i=i+1-1;
}
}
s=0;
}
m=0;
}
goto start;
}
[/code]