title: C++ Multiple statements for conditional operator
body: <p>I'm trying to use a conditional statement that does one thing in one condition but does two things if the other condition applies.</p>
  
  <p>Consider the following:</p>
  
  <pre><code> ( h &gt;= 0 &amp;&amp; h &lt; 24 ? hour = h : hour = 0, cout &lt;&lt; "Invalid Hour Detected\n")
  </code></pre>
  
  <p>If "h" is set to 25, it sets "hour" to 0 correctly.
  If "h" is set to 12, it correctly sets "hour" to 12.</p>
  
  <p>The problem is that it outputs "Invalid Hour Detected" for both true and false conditions.
  I only want it to output if the conditions aren't met.</p>
  
  <p>Essentially, I'm wondering if it is possible in a conditional statement to do two things for one condition.</p>
  
  <p>Also tried:</p>
  
  <pre><code>( h &gt;= 0 &amp;&amp; h &lt; 24 ? hour = h : hour = 0 &amp;&amp; cout &lt;&lt; "Invalid Hour Detected\n")
  </code></pre>
  
  <p>but that didn't run the cout on either case.</p>