<?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"
	>
<channel>
	<title>Comments on: 3.2 &#8212; Arithmetic operators</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/</link>
	<description></description>
	<pubDate>Sun, 20 Jul 2008 14:15:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Mitul Golakiya</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-19256</link>
		<dc:creator>Mitul Golakiya</dc:creator>
		<pubDate>Wed, 18 Jun 2008 09:22:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-19256</guid>
		<description>/* Program to know Number is Odd, Even OR Zero */

/* In torbo C++ , There are not bool Data-Type */

#include &#60;iostream.h&#62;
#include &#60;conio.h&#62;

void main()
{
	int value;
	clrscr();
	cout &#60;&#60; &#34;n Enter the value : &#34;;
	cin &#62;&#62; value;
	if(value == 0)
	{
		cout &#60;&#60; &#34;n You have enterd zero.&#34;;
	}
	else if(value % 2 == 0)
	{
		cout &#60;&#60; &#34;n You have enterd even number.&#34;;
	}
	else
	{
		cout &#60;&#60; &#34;n Tou have enterd odd number.&#34;;
	}
	getch();
}

/* End of Program */</description>
		<content:encoded><![CDATA[<p>/* Program to know Number is Odd, Even OR Zero */</p>
<p>/* In torbo C++ , There are not bool Data-Type */</p>
<p>#include &lt;iostream.h&gt;<br />
#include &lt;conio.h&gt;</p>
<p>void main()<br />
{<br />
	int value;<br />
	clrscr();<br />
	cout &lt;&lt; &quot;n Enter the value : &quot;;<br />
	cin &gt;&gt; value;<br />
	if(value == 0)<br />
	{<br />
		cout &lt;&lt; &quot;n You have enterd zero.&quot;;<br />
	}<br />
	else if(value % 2 == 0)<br />
	{<br />
		cout &lt;&lt; &quot;n You have enterd even number.&quot;;<br />
	}<br />
	else<br />
	{<br />
		cout &lt;&lt; &quot;n Tou have enterd odd number.&quot;;<br />
	}<br />
	getch();<br />
}</p>
<p>/* End of Program */</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 3.1 &#8212; Precedence and associativity</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-12638</link>
		<dc:creator>Learn C++ - &#187; 3.1 &#8212; Precedence and associativity</dc:creator>
		<pubDate>Wed, 23 Apr 2008 02:34:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-12638</guid>
		<description>[...]   &#171; Three questions that need to be answered before you start writing your game &#124; Home &#124; 3.2 &#8212; Arithmetic operators &#187;     Wednesday, June 13th, 2007 at 3:55 [...]</description>
		<content:encoded><![CDATA[<p>[...]   &laquo; Three questions that need to be answered before you start writing your game | Home | 3.2 &#8212; Arithmetic operators &raquo;     Wednesday, June 13th, 2007 at 3:55 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 3.3 &#8212; Increment/decrement operators, and side effects</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-12608</link>
		<dc:creator>Learn C++ - &#187; 3.3 &#8212; Increment/decrement operators, and side effects</dc:creator>
		<pubDate>Wed, 23 Apr 2008 01:50:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-12608</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; 3.2 &#8212; Arithmetic operators &#124; Home &#124; 3.4 &#8212; Sizeof, comma, and arithmetic if operators &#187;     Wednesday, June 13th, [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; 3.2 &#8212; Arithmetic operators | Home | 3.4 &#8212; Sizeof, comma, and arithmetic if operators &raquo;     Wednesday, June 13th, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Bernier</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-8794</link>
		<dc:creator>Chad Bernier</dc:creator>
		<pubDate>Sun, 02 Mar 2008 22:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-8794</guid>
		<description>I don't understand.  That uses more advanced stuff than stated so far.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t understand.  That uses more advanced stuff than stated so far.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivailosp</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-6634</link>
		<dc:creator>Ivailosp</dc:creator>
		<pubDate>Sat, 26 Jan 2008 12:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-6634</guid>
		<description>&lt;PRE&gt;
bool isEven(int x) {
	return !(x&#038;1);
}

int main() {
	int x;
	std::cout &lt;&lt; "Enter a Number: ";
	std::cin &gt;&gt; x;
	std::cout &lt;&lt; (isEven(x) ? "even" : "odd");
	return 0;
}
&lt;/PRE&gt;</description>
		<content:encoded><![CDATA[<pre>
bool isEven(int x) {
	return !(x&#038;1);
}

int main() {
	int x;
	std::cout < < "Enter a Number: ";
	std::cin >> x;
	std::cout < < (isEven(x) ? "even" : "odd");
	return 0;
}
</pre></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen01</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-6622</link>
		<dc:creator>Allen01</dc:creator>
		<pubDate>Sat, 26 Jan 2008 06:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-6622</guid>
		<description>Ok, figured it out, adjusted the main cout based on the IsEven condition.

&lt;PRE&gt;
bool IsEven(int x)
{
    // if x % 2 == 0, 2 divides evenly into our number
    // which means it must be an even number

    if (x % 2 == 0)
        return true;
    else
        return false;
}
&lt;/PRE&gt;

&lt;PRE&gt;
int main()
{
using namespace std;
cout &lt;&lt; "Enter a Number" &lt;&lt; endl;
int x;
cin &gt;&gt; x;

if (IsEven(x))
	cout &lt;&lt; "Even integer, returned true" &lt;&lt; endl;
	
else 
	cout &lt;&lt; "odd interger, returned false" &lt;&lt; endl;

return 0;
}
&lt;/PRE&gt;</description>
		<content:encoded><![CDATA[<p>Ok, figured it out, adjusted the main cout based on the IsEven condition.</p>
<pre>
bool IsEven(int x)
{
    // if x % 2 == 0, 2 divides evenly into our number
    // which means it must be an even number

    if (x % 2 == 0)
        return true;
    else
        return false;
}
</pre>
<pre>
int main()
{
using namespace std;
cout < < "Enter a Number" << endl;
int x;
cin >> x;

if (IsEven(x))
	cout < < "Even integer, returned true" << endl;

else
	cout << "odd interger, returned false" << endl;

return 0;
}
</pre></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-6617</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sat, 26 Jan 2008 05:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-6617</guid>
		<description>The return value of main is passed back to whomever launched your program (either another program, or the operating system).  What happens with this value is up to the caller.  If you want this value to print out, you should print it before you return it.</description>
		<content:encoded><![CDATA[<p>The return value of main is passed back to whomever launched your program (either another program, or the operating system).  What happens with this value is up to the caller.  If you want this value to print out, you should print it before you return it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen01</title>
		<link>http://www.learncpp.com/cpp-tutorial/32-arithmetic-operators/#comment-6613</link>
		<dc:creator>Allen01</dc:creator>
		<pubDate>Sat, 26 Jan 2008 02:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/32-arithmetic-operators/#comment-6613</guid>
		<description>Working on exercise 2), I first tried the code below. It compiled but when run, the command prompt only displayed: "Press any key to continue..."  Shouldn't it have displayed a "1" since it did return as true?
&lt;sourcecode language='cpp'&gt;
int main()
{	
	using namespace std;
	
	bool IsEven(int x);
	int x = 4;

	if (x % 2 == 0)
		return true;
    else
		return false;
	
	return 0;
}
&lt;/sourcecode&gt;



I experimented a bit a finally got the code below to work:

&lt;sourcecode language='cpp'&gt;
int main()
{	
	using namespace std;
	
	bool IsEven(int x);
	int x = 4;

	if (x % 2 == 0)
		cout &lt;&lt; "My name is Even Steven" &lt;&lt; endl;
    else
		cout &lt;&lt; "My name is NOT Even Steven" &lt;&lt; endl;
	
	

	return 0;
}
&lt;/sourcecode&gt;

This time, the output was "My name is Even Steven", showing that 4  was an even integer.

Why would it not output a 1 for the true condition in the top code?
</description>
		<content:encoded><![CDATA[<p>Working on exercise 2), I first tried the code below. It compiled but when run, the command prompt only displayed: &#8220;Press any key to continue&#8230;&#8221;  Shouldn&#8217;t it have displayed a &#8220;1&#8243; since it did return as true?<br />
<sourcecode language='cpp'><br />
int main()<br />
{<br />
	using namespace std;</p>
<p>	bool IsEven(int x);<br />
	int x = 4;</p>
<p>	if (x % 2 == 0)<br />
		return true;<br />
    else<br />
		return false;</p>
<p>	return 0;<br />
}<br />
</sourcecode></p>
<p>I experimented a bit a finally got the code below to work:</p>
<p><sourcecode language='cpp'><br />
int main()<br />
{<br />
	using namespace std;</p>
<p>	bool IsEven(int x);<br />
	int x = 4;</p>
<p>	if (x % 2 == 0)<br />
		cout < < "My name is Even Steven" << endl;<br />
    else<br />
		cout << "My name is NOT Even Steven" << endl;</p>
<p>	return 0;<br />
}<br />
</sourcecode></p>
<p>This time, the output was &#8220;My name is Even Steven&#8221;, showing that 4  was an even integer.</p>
<p>Why would it not output a 1 for the true condition in the top code?</sourcecode></p>
]]></content:encoded>
	</item>
</channel>
</rss>
