title: How can I use C to validate that the difference between two numbers is no more than X
body: <p>I've pasted some code below to give a brief outline of what I'm writing. I basically need to say that if the difference between presentMeterReading and currentMeterReading is &gt; 1000.. give me an error.</p>
  <p>for example.</p>
  <pre><code>printf(&quot;Usage is high at over 1000&quot;); 
  </code></pre>
  <pre><code>if (presentMeterReading &lt; 0 || presentMeterReading &gt; 9999)
  printf(&quot;That's out of range. Meter readings should be between 0 - 9999 \n&quot;);
  
  if (previousMeterReading &lt; presentMeterReading || presentMeterReading &gt; previousMeterReading)
  
  printf(&quot;Present readings should not be more than previous readings.&quot;);
  
  if (dayReadingTaken &gt; 12 || dayReadingTaken &lt; 1)
  
  printf(&quot;That's not a valid month.&quot;);
  </code></pre>