title: C++ code - Error message when floating point is entered
body: <p>I think this will be a simple question for anyone with knowledge of C++. I am new to C++ (please be gentle). I am trying to write a bit of code that asks the user to enter a whole number greater than 0. If they enter 0, they get an error message, if they enter a negative number they get an error and when they enter a floating point, they get an error. The code I have seems to do all except the floating point. Can someone please help?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
   int n;
   
   cout &lt;&lt;&quot;Please enter a number:  &quot; &lt;&lt; endl;
   cin &gt;&gt; n ; 
   
   if(n == 0)
   
   {
   cout &lt;&lt; &quot;You entered 0, please enter a whole number greater than 0&quot; &lt;&lt; endl; 
   }
   
   if(n &lt; 0) {
       
       cout &lt;&lt;&quot;You have entered a negative number&quot; &lt;&lt; endl;
       
   }
   
   else {
       
       cout &lt;&lt;&quot;you entered: &quot; &lt;&lt; n &lt;&lt; endl;
       
   }
   return 0;
   
  }
  </code></pre>