Question on Loops

 

Here's a simple loop which counts from 0 to 60. How do I get this loop to start over again at 0?

int start()
{

int t=0;
while (t<60)

{
Sleep(1000);
Alert (t);
t++;
}





//----
return(0);

 
the simple answer is after t++; add if (t==60) t=0; but then, you would be trapped in the loop forever. So, there must also be some condition to escape the loop. jdc
 
jingodelcuyo wrote >>
the simple answer is after t++; add if (t==60) t=0; but then, you would be trapped in the loop forever. So, there must also be some condition to escape the loop. jdc

That's great! It worked. I was just writing it out wrong.

if ( t == 60 )

{ t == 0 }

BASIC was easier.

100 FORT=0TO60:NEXTT

200 ?T

300 GOTO100

Thanks again! Knew it had to be simple.

Reason: