title: Code for a function that just returns after an hour -interview question
body: <p>I saw this question online from an interview:</p>
  <p>Suppose you have this code:</p>
  <pre><code>void myFunction(){
    int time = clcTime();
    while (clcTime()-time!=3600);  
  }
  </code></pre>
  <p>When <code>clcTime()</code> is a method that returns the seconds that passed since 00:00 of today.</p>
  <p>(1). Find what this code snippet does.<br />
  (2). Some QA tester said this code fails at specific case. What's that case and how can you solve that issue?<br />
  (3). Another QA tester that during the day this code worked fine, but when he got to sleep - something went wrong. What can possibly be the problem and how can you solve it?</p>
  <p>My attempt:<br />
  For (1), I think this function just suppose to run in a loop for an hour.<br />
  For (3), I think the problem is when the <code>time</code> variable get its value when the current hour of the day is in the range <code>[23:00:00,23:59:59]</code>. And that's because on that case, the value of <code>time</code> will be in the range <code>[23*3600,23*3600 + 3599]</code> and <code>clcTime()</code> can't return a matching value in the range <code>[24*3600, 24*3600 + 3599]</code>. So in that case, we know that the condition 'clcTime()-time' will never get a value of 3600 and we will get an infinite loop.</p>
  <p>My suggestion for solving it is replacing the <code>while</code> line with those lines:</p>
  <pre><code>int measure = clcTime() - time;
  int measureModulo = measure % 3600;
  
  while (measure==0 || measureModulo!=0){
      measure = clcTime() - time;
      measureModulo = measure % 3600;
  }             
                   
           
  </code></pre>
  <p>The only problem I still have is that I can't figure out (2) - I don't find any other problem with this code.</p>
  <p>Do you have any idea what else can be problematic with this code?<br />
  Also, please feel free to correct me if I was wrong with what I wrote for (1) and (3).</p>