title: How can I make the if statement here check for integer numbers?
body: <p>I would like only integer inputs for month and day so that it gives an error message when one uses a decimal number. How can I do that in this code? I have looked on line but I can't understand what I am looking at.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main()
  {
  int month, day;
  
  cout &lt;&lt; "Enter a month (use 1 for Jan, etc.): ";    
  cin &gt;&gt; month;
  if (month&lt;1 || month&gt;12)
      cout &lt;&lt; "Invalid month entered\n";
  
  cout &lt;&lt; "Enter a day of the month: ";
  cin &gt;&gt; day;
  if (day&lt;1 || day&gt;31)
      cout &lt;&lt; "Invalid day entered\n";
  
  return 0;
  }
  </code></pre>