create a timer without using loops

no while or for loops allowed. It has to be a function that is repeatedly called for different values given in seconds. I have seen many codes for timers on the net, but they all seemingly use some type of loops.

1
2
3
4
5
6
7
8
9
10

void wait(int seconds)
{
  clock_t waiting;
  waiting=clock () +seconds* CLK_TCK;
  while (clock() <= waiting)
  {

  }
}


How can I implement if statements into that instead of while?
OK then do...while loops hahahaa. just kidding.
On a more serious note why don't you try recursion?
Topic archived. No new replies allowed.