<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 3.6 &#8212; Logical operators</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/36-logical-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 12:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: jimbo</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-96709</link>
		<dc:creator>jimbo</dc:creator>
		<pubDate>Tue, 20 Dec 2011 21:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-96709</guid>
		<description>Hi guys and Alex. First of all thanks a lot for this great tutorial. I understand all the information youv&#039;e provided on logical operators or at least I think I do. However the quiz has totally threw me I don&#039;t understand it at all. If someone could break it down (the quiz) so it&#039;s easier to understand it would be much appreciated. Many thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi guys and Alex. First of all thanks a lot for this great tutorial. I understand all the information youv&#8217;e provided on logical operators or at least I think I do. However the quiz has totally threw me I don&#8217;t understand it at all. If someone could break it down (the quiz) so it&#8217;s easier to understand it would be much appreciated. Many thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rand_Al_Thor</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-95472</link>
		<dc:creator>Rand_Al_Thor</dc:creator>
		<pubDate>Wed, 18 May 2011 19:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-95472</guid>
		<description>Heyyy, look at me! I have a nice, polished, streak-free new account! Check out the shine on this baby. :) 

About the quiz questions for this section of the chapter, I know they are meant to test my knowledge of the level of precedence logical AND and logical OR operators have when used in the same expression, but I can&#039;t figure out how to &quot;answer&quot; them after Quiz Question #3. 

I got the first two fine, but I get a little lost when the third one goes into &quot;&#124;&#124; true == false&quot;. I thought it would be &quot;&#124;&#124; false == false&quot; or &quot;&#124;&#124; false == true&quot;, not the other way around? 

I know it seems like a trivial question, but I need to understand this.</description>
		<content:encoded><![CDATA[<p>Heyyy, look at me! I have a nice, polished, streak-free new account! Check out the shine on this baby. :) </p>
<p>About the quiz questions for this section of the chapter, I know they are meant to test my knowledge of the level of precedence logical AND and logical OR operators have when used in the same expression, but I can&#8217;t figure out how to &#8220;answer&#8221; them after Quiz Question #3. </p>
<p>I got the first two fine, but I get a little lost when the third one goes into &#8220;|| true == false&#8221;. I thought it would be &#8220;|| false == false&#8221; or &#8220;|| false == true&#8221;, not the other way around? </p>
<p>I know it seems like a trivial question, but I need to understand this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jake</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-86896</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Sun, 20 Jun 2010 20:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-86896</guid>
		<description>...you type them, just like anywhere else. they&#039;re on your keyboard</description>
		<content:encoded><![CDATA[<p>&#8230;you type them, just like anywhere else. they&#8217;re on your keyboard</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cyrus</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-85575</link>
		<dc:creator>Cyrus</dc:creator>
		<pubDate>Sat, 29 May 2010 17:14:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-85575</guid>
		<description>This is known as short circuit evaluation, and it is done &lt;pre&gt;primary&lt;/pre&gt; for optimization purposes.

Should be PRIMARILY :]</description>
		<content:encoded><![CDATA[<p>This is known as short circuit evaluation, and it is done
<pre>primary</pre>
<p> for optimization purposes.</p>
<p>Should be PRIMARILY :]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shinjan</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-82478</link>
		<dc:creator>shinjan</dc:creator>
		<pubDate>Thu, 08 Apr 2010 05:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-82478</guid>
		<description>Just wondering, if this &quot;short circuit&quot; is something which is compiler dependent. There could be many architectures (esp DSP processors) where multiple instructions can be issued on multiple ALUs (VLIW architectures). For e.g. in (x == 1 &amp;&amp; y++ == 2), compiler might generate a code for (x==1) and y++ to go in the same cycle. Do you think it is mandatory that compilers have to implement &quot;short circuit&quot;.</description>
		<content:encoded><![CDATA[<p>Just wondering, if this &#8220;short circuit&#8221; is something which is compiler dependent. There could be many architectures (esp DSP processors) where multiple instructions can be issued on multiple ALUs (VLIW architectures). For e.g. in (x == 1 &amp;&amp; y++ == 2), compiler might generate a code for (x==1) and y++ to go in the same cycle. Do you think it is mandatory that compilers have to implement &#8220;short circuit&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lsandling</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-77867</link>
		<dc:creator>lsandling</dc:creator>
		<pubDate>Thu, 04 Feb 2010 22:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-77867</guid>
		<description>so how do you get these symbols in Code::Blocks</description>
		<content:encoded><![CDATA[<p>so how do you get these symbols in Code::Blocks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaonashi</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-73867</link>
		<dc:creator>Kaonashi</dc:creator>
		<pubDate>Tue, 08 Dec 2009 15:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-73867</guid>
		<description>Never mind... I see my mistake; I should&#039;ve used the &#124;&#124; operator.

Thanks for a great tutorial, Alex!</description>
		<content:encoded><![CDATA[<p>Never mind&#8230; I see my mistake; I should&#8217;ve used the || operator.</p>
<p>Thanks for a great tutorial, Alex!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaonashi</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-73866</link>
		<dc:creator>Kaonashi</dc:creator>
		<pubDate>Tue, 08 Dec 2009 15:30:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-73866</guid>
		<description>Can you use the logical operators in do...while loops? I try to check an user-entered integer if it&#039;s between 1 and 10. I use the &amp;&amp; operator, but I can&#039;t get it to work properly.

Here&#039;s the code:

&lt;pre&gt;
int nInvoer=0;
do
	{
	cout &lt;&lt; &quot;Enter number (1 - 10): &quot;; 
	cin &gt;&gt; nInvoer; 			
	}
while (nInvoer &lt; 1 &amp;&amp; nInvoer &gt;= 10 ); 

	// Do here if entered value is between 1 and 10.
&lt;!--formatted--&gt;&lt;/pre&gt; 

Whatever value I enter, the program always goes to the next part. If I check either &lt;pre&gt;nInvoer &lt; 1 &lt;!--formatted--&gt;&lt;/pre&gt; or &lt;pre&gt;nInvoer &gt;=10&lt;!--formatted--&gt;&lt;/pre&gt;  it works properly, but I can&#039;t check both at the same time...</description>
		<content:encoded><![CDATA[<p>Can you use the logical operators in do&#8230;while loops? I try to check an user-entered integer if it&#8217;s between 1 and 10. I use the &amp;&amp; operator, but I can&#8217;t get it to work properly.</p>
<p>Here&#8217;s the code:</p>
<pre>
int nInvoer=0;
do
	{
	cout &lt;&lt; &quot;Enter number (1 - 10): &quot;;
	cin &gt;&gt; nInvoer;
	}
while (nInvoer &lt; 1 &amp;&amp; nInvoer &gt;= 10 ); 

	// Do here if entered value is between 1 and 10.
<!--formatted--></pre>
<p>Whatever value I enter, the program always goes to the next part. If I check either
<pre>nInvoer &lt; 1 <!--formatted--></pre>
<p> or
<pre>nInvoer &gt;=10<!--formatted--></pre>
<p>  it works properly, but I can&#8217;t check both at the same time&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-73640</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Fri, 04 Dec 2009 21:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-73640</guid>
		<description>Hey Ronnie,

I just thought about your XOR question and came to this solution (since their is no XOR to use directly in c++)
 
(!america &amp;&amp; russia) &#124;&#124; (america &amp;&amp; !russia)

lets just take a logic look behind this:

&lt;pre&gt;//example 1: 
//america false, russia false
(!false &amp;&amp; false) &#124;&#124; (false &amp;&amp; !false) == false &#124;&#124; false == false&lt;!--formatted--&gt;&lt;/pre&gt;

&lt;pre&gt;//example 2 &amp; 3:
//america true, russia false (vice versa is the same result)
(!true &amp;&amp; false) &#124;&#124; (true &amp;&amp; !false) == true &#124;&#124; true == true&lt;!--formatted--&gt;&lt;/pre&gt;

&lt;pre&gt;//example 4:
//america true, russia true
(!true &amp;&amp; true) &#124;&#124; (true &amp;&amp; !true) == false &#124;&#124; false == false&lt;!--formatted--&gt;&lt;/pre&gt;

So basically with only 2 conditions it is easy to handle. How did you manage to pick that example?! :)

wish you all a nice weekend
Florian</description>
		<content:encoded><![CDATA[<p>Hey Ronnie,</p>
<p>I just thought about your XOR question and came to this solution (since their is no XOR to use directly in c++)</p>
<p>(!america &amp;&amp; russia) || (america &amp;&amp; !russia)</p>
<p>lets just take a logic look behind this:</p>
<pre>//example 1:
//america false, russia false
(!false &amp;&amp; false) || (false &amp;&amp; !false) == false || false == false<!--formatted--></pre>
<pre>//example 2 &amp; 3:
//america true, russia false (vice versa is the same result)
(!true &amp;&amp; false) || (true &amp;&amp; !false) == true || true == true<!--formatted--></pre>
<pre>//example 4:
//america true, russia true
(!true &amp;&amp; true) || (true &amp;&amp; !true) == false || false == false<!--formatted--></pre>
<p>So basically with only 2 conditions it is easy to handle. How did you manage to pick that example?! :)</p>
<p>wish you all a nice weekend<br />
Florian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RonnieTheBear</title>
		<link>http://www.learncpp.com/cpp-tutorial/36-logical-operators/comment-page-1/#comment-72575</link>
		<dc:creator>RonnieTheBear</dc:creator>
		<pubDate>Thu, 19 Nov 2009 20:39:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/36-logical-operators/#comment-72575</guid>
		<description>Hi Alex. Love the tutorials, especially how you try to relate things back to machine code and whatnot. Truly deepens my understanding. Quick question: is there not an exclusive OR? i.e. if either x OR y are true, but NOT if both are? i.e. 

America has nukes     / Russia has nukes   /    World gets destroyed

false               /   false        /          false
true         /          false        /          true
false          /        true       /            true
true          /         true        /           false [MAD theory ;)]

Or is there a combination of ANDs and ORs and NOTs to achieve this?</description>
		<content:encoded><![CDATA[<p>Hi Alex. Love the tutorials, especially how you try to relate things back to machine code and whatnot. Truly deepens my understanding. Quick question: is there not an exclusive OR? i.e. if either x OR y are true, but NOT if both are? i.e. </p>
<p>America has nukes     / Russia has nukes   /    World gets destroyed</p>
<p>false               /   false        /          false<br />
true         /          false        /          true<br />
false          /        true       /            true<br />
true          /         true        /           false [MAD theory ;)]</p>
<p>Or is there a combination of ANDs and ORs and NOTs to achieve this?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

