title: How to make your program defensive against the situation of overflow by using “limits” header?
body: <p>This is the code I have made, Please tell me how to make it defensive against the situation of overflow by using "limits" header.</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  #define MAX 100
  int main()
  {
      cout&lt;&lt;"decimal to binary conversion"&lt;&lt;endl;
      bool binary[MAX];
  
  
  
      int decimal_num,i;
      cout&lt;&lt;"decimal number:"&lt;&lt;endl;
      cin&gt;&gt;decimal_num;
  
      for(i=0; (decimal_num/2)!=0; ++i)
      {
          binary[i]=decimal_num%2;
          decimal_num/=2;
  
      }
      binary[i]=decimal_num;
      cout&lt;&lt;endl;
      cout&lt;&lt;"Binary equivalent :"&lt;&lt;endl;
      for(i; i&gt;=0;--i)
      {
          cout&lt;&lt;binary[i];
      }
      cout&lt;&lt;endl&lt;&lt;endl;
      return 0;
  }
  </code></pre>