<?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: 6.3 &#8212; Arrays and loops</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 21:20:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: eect13</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-96576</link>
		<dc:creator>eect13</dc:creator>
		<pubDate>Thu, 08 Dec 2011 15:48:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-96576</guid>
		<description>cant paste my code properly sorry</description>
		<content:encoded><![CDATA[<p>cant paste my code properly sorry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eect13</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-96575</link>
		<dc:creator>eect13</dc:creator>
		<pubDate>Thu, 08 Dec 2011 15:47:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-96575</guid>
		<description>#include 
using namespace std;

void main()
{
	int number;
	do
	{
		cout &lt;&gt; number;
	}
	while(number  9);

	int array[] = {1,3,2,5,8,11,4,9,21,24};

	for (int index = 0; index &lt;= 9; index++)
	{
		cout &lt;&lt; array[index] &lt;&lt; &quot; &quot;;
	}
	cout &lt;&lt; endl &lt;&lt; number &lt;&lt; &quot; has index &quot; &lt;&lt; array[number] &lt;&lt; endl;

	system(&quot;pause&quot;);
}</description>
		<content:encoded><![CDATA[<p>#include<br />
using namespace std;</p>
<p>void main()<br />
{<br />
	int number;<br />
	do<br />
	{<br />
		cout &lt;&gt; number;<br />
	}<br />
	while(number  9);</p>
<p>	int array[] = {1,3,2,5,8,11,4,9,21,24};</p>
<p>	for (int index = 0; index &lt;= 9; index++)<br />
	{<br />
		cout &lt;&lt; array[index] &lt;&lt; &quot; &quot;;<br />
	}<br />
	cout &lt;&lt; endl &lt;&lt; number &lt;&lt; &quot; has index &quot; &lt;&lt; array[number] &lt;&lt; endl;</p>
<p>	system(&quot;pause&quot;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eect13</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-96574</link>
		<dc:creator>eect13</dc:creator>
		<pubDate>Thu, 08 Dec 2011 15:45:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-96574</guid>
		<description>is my solution same on #2?

#include 
using namespace std;

void main()
{
	int number;
	do
	{
		cout &lt;&gt; number;
	}
	while(number  9);

	int array[] = {1,3,2,5,8,11,4,9,21,24};

	for (int index = 0; index &lt;= 9; index++)
	{
		cout &lt;&lt; array[index] &lt;&lt; &quot; &quot;;
	}
	cout &lt;&lt; endl &lt;&lt; number &lt;&lt; &quot; has index &quot; &lt;&lt; array[number] &lt;&lt; endl;

	system(&quot;pause&quot;);
}</description>
		<content:encoded><![CDATA[<p>is my solution same on #2?</p>
<p>#include<br />
using namespace std;</p>
<p>void main()<br />
{<br />
	int number;<br />
	do<br />
	{<br />
		cout &lt;&gt; number;<br />
	}<br />
	while(number  9);</p>
<p>	int array[] = {1,3,2,5,8,11,4,9,21,24};</p>
<p>	for (int index = 0; index &lt;= 9; index++)<br />
	{<br />
		cout &lt;&lt; array[index] &lt;&lt; &quot; &quot;;<br />
	}<br />
	cout &lt;&lt; endl &lt;&lt; number &lt;&lt; &quot; has index &quot; &lt;&lt; array[number] &lt;&lt; endl;</p>
<p>	system(&quot;pause&quot;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinky</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-95357</link>
		<dc:creator>pinky</dc:creator>
		<pubDate>Fri, 22 Apr 2011 12:20:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-95357</guid>
		<description>hi, i am having a problem in this program:
int _tmain(int argc, _TCHAR* argv[])
{
	
    int n=0 ,num;
	int list[4];
	int j;
	cout&lt;&lt;&quot;Enter 5 numbers&quot;&lt;&gt; list[n])
	{
        n++;
		if (n== 4);
			//break;
    }*/
	for(int i=0 ; i&gt;list[i];
	}
	cout&lt;&lt;&quot;Enter a number &quot;&lt;&gt;num;
	for(j=0;j&lt;5;j++)
	{
		if(list[j]==num)
		{
			cout&lt;&lt;&quot;The number of term is: &quot;&lt;&lt;j&lt;&lt;endl;
		}
	}

    
	return 0;
}
// i know how to run it using while loop but a debug error occurs while using a for loop.
please answer</description>
		<content:encoded><![CDATA[<p>hi, i am having a problem in this program:<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{</p>
<p>    int n=0 ,num;<br />
	int list[4];<br />
	int j;<br />
	cout&lt;&lt;&quot;Enter 5 numbers&quot;&lt;&gt; list[n])<br />
	{<br />
        n++;<br />
		if (n== 4);<br />
			//break;<br />
    }*/<br />
	for(int i=0 ; i&gt;list[i];<br />
	}<br />
	cout&lt;&lt;&quot;Enter a number &quot;&lt;&gt;num;<br />
	for(j=0;j&lt;5;j++)<br />
	{<br />
		if(list[j]==num)<br />
		{<br />
			cout&lt;&lt;&quot;The number of term is: &quot;&lt;&lt;j&lt;&lt;endl;<br />
		}<br />
	}</p>
<p>	return 0;<br />
}<br />
// i know how to run it using while loop but a debug error occurs while using a for loop.<br />
please answer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bonno</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-95075</link>
		<dc:creator>bonno</dc:creator>
		<pubDate>Sun, 26 Dec 2010 13:05:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-95075</guid>
		<description>hi people... i&#039;ve written some codes to compose a multiplying equation that consist of every integer from 1 to 9.
anybody have any idea to simplify my codes so that it won&#039;t look so messy?

#include &quot;stdafx.h&quot;
#include 

int main()
	{
		using namespace std;

		int anX[9];
		
	    for(anX[0]=1; anX[0]&lt;5; anX[0]++)
			{
				for(anX[1]=1; anX[1]&lt;10; anX[1]++)
					{
						if(anX[0]==anX[1])
							continue;
						for(anX[2]=1; anX[2]&lt;10; anX[2]++)
							{
								if(anX[1]==anX[2])
									continue;
								for(anX[3]=1; anX[3]&lt;10; anX[3]++)
									{
										if(anX[2]==anX[3])
											continue;
										for(anX[4]=1; anX[4] 9999 &#124;&#124; aaa &lt; 1000)
															continue;
														anX[5] = aaa/1000;
														anX[6] = (aaa - anX[5]*1000)/100;
														anX[7] = (aaa - anX[5]*1000 - anX[6]*100)/10;
														anX[8] = aaa - anX[5]*1000 - anX[6]*100 - anX[7]*10;
														if(anX[5]==0 &#124;&#124; anX[6]==0 &#124;&#124; anX[7]==0 &#124;&#124; anX[8]==0)
															continue;
														bool result = true;

														for(int iii=0; iii&lt;9; iii++)
															for(int jjj=0; jjj&lt;9; jjj++)
																{
																	if(iii!=jjj &amp;&amp; anX[iii]==anX[jjj])
																		result = false;
																}
															if(result)
																{
																	cout &lt;&lt; &quot;The Result is?&quot; &lt;&lt; endl;
																	int bbb = anX[0]*1000 + anX[1]*100 + anX[2]*10 + anX[3];
																	int ccc = bbb * anX[4];
																	cout &lt;&lt; bbb &lt;&lt; &quot; * &quot; &lt;&lt; anX[4] &lt;&lt; &quot; = &quot; &lt;&lt; ccc &lt;&lt; endl;
																}
													}
											}
									}
							}
					}
			}
			cout &lt;&lt; &quot;The End?&quot; &lt;&lt; endl;
	}</description>
		<content:encoded><![CDATA[<p>hi people&#8230; i&#8217;ve written some codes to compose a multiplying equation that consist of every integer from 1 to 9.<br />
anybody have any idea to simplify my codes so that it won&#8217;t look so messy?</p>
<p>#include &#8220;stdafx.h&#8221;<br />
#include </p>
<p>int main()<br />
	{<br />
		using namespace std;</p>
<p>		int anX[9];</p>
<p>	    for(anX[0]=1; anX[0]&lt;5; anX[0]++)<br />
			{<br />
				for(anX[1]=1; anX[1]&lt;10; anX[1]++)<br />
					{<br />
						if(anX[0]==anX[1])<br />
							continue;<br />
						for(anX[2]=1; anX[2]&lt;10; anX[2]++)<br />
							{<br />
								if(anX[1]==anX[2])<br />
									continue;<br />
								for(anX[3]=1; anX[3]&lt;10; anX[3]++)<br />
									{<br />
										if(anX[2]==anX[3])<br />
											continue;<br />
										for(anX[4]=1; anX[4] 9999 || aaa &lt; 1000)<br />
															continue;<br />
														anX[5] = aaa/1000;<br />
														anX[6] = (aaa &#8211; anX[5]*1000)/100;<br />
														anX[7] = (aaa &#8211; anX[5]*1000 &#8211; anX[6]*100)/10;<br />
														anX[8] = aaa &#8211; anX[5]*1000 &#8211; anX[6]*100 &#8211; anX[7]*10;<br />
														if(anX[5]==0 || anX[6]==0 || anX[7]==0 || anX[8]==0)<br />
															continue;<br />
														bool result = true;</p>
<p>														for(int iii=0; iii&lt;9; iii++)<br />
															for(int jjj=0; jjj&lt;9; jjj++)<br />
																{<br />
																	if(iii!=jjj &amp;&amp; anX[iii]==anX[jjj])<br />
																		result = false;<br />
																}<br />
															if(result)<br />
																{<br />
																	cout &lt;&lt; &quot;The Result is?&quot; &lt;&lt; endl;<br />
																	int bbb = anX[0]*1000 + anX[1]*100 + anX[2]*10 + anX[3];<br />
																	int ccc = bbb * anX[4];<br />
																	cout &lt;&lt; bbb &lt;&lt; &quot; * &quot; &lt;&lt; anX[4] &lt;&lt; &quot; = &quot; &lt;&lt; ccc &lt;&lt; endl;<br />
																}<br />
													}<br />
											}<br />
									}<br />
							}<br />
					}<br />
			}<br />
			cout &lt;&lt; &quot;The End?&quot; &lt;&lt; endl;<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C++ Tutorial and Online Ebook</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-87428</link>
		<dc:creator>C++ Tutorial and Online Ebook</dc:creator>
		<pubDate>Wed, 30 Jun 2010 01:11:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-87428</guid>
		<description>[...] 6.3 Arrays and loops [...]</description>
		<content:encoded><![CDATA[<p>[...] 6.3 Arrays and loops [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-84916</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Tue, 18 May 2010 21:54:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-84916</guid>
		<description>Hey  - the below code is copy pasted directly from Microsoft Visual 2010 and as far as i can see its exactly the same as the solution Alex posted. 

I&#039;m new to learning c++, and I&#039;m really enjoying following this tutorial. 

My question is this:
When i run the program it correctly keeps asking for a number between 1 and 9 as long as i input a number when prompted. However if I input a letter (Tried it to see what would happen incase of a misstype) it seems to go into an endless loop. Is it supposed to do that (with the code written) or is there another way to avoid this problem I should implement?

&lt;pre&gt;#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
using namespace std;

int main()
{
	int x;
	do
	{
		cout &lt;&lt; &quot;Please input a number between 1 and 9: &quot;;
		cin &gt;&gt; x;
	}	while (x &lt; 1 &#124;&#124; x &gt; 9);
	
	int anArray[9] = {4, 6, 7, 3, 8, 2, 1, 9, 5};
	for (int iii = 0; iii &lt; 9; iii++)
		cout &lt;&lt; anArray[iii] &lt;&lt; &quot; &quot;;
	
	cout &lt;&lt; endl;
	
	for (int jjj = 0; jjj &lt; 9; jjj++)
	{
		if (anArray[jjj] == x)
		{
			cout &lt;&lt; &quot;The number you entered (&quot; &lt;&lt; x &lt;&lt; &quot;) has index number: &quot; &lt;&lt; jjj &lt;&lt; endl;
			break;
		}
	}

	return 0;
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hey  &#8211; the below code is copy pasted directly from Microsoft Visual 2010 and as far as i can see its exactly the same as the solution Alex posted. </p>
<p>I&#8217;m new to learning c++, and I&#8217;m really enjoying following this tutorial. </p>
<p>My question is this:<br />
When i run the program it correctly keeps asking for a number between 1 and 9 as long as i input a number when prompted. However if I input a letter (Tried it to see what would happen incase of a misstype) it seems to go into an endless loop. Is it supposed to do that (with the code written) or is there another way to avoid this problem I should implement?</p>
<pre>#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
using namespace std;

int main()
{
	int x;
	do
	{
		cout &lt;&lt; &quot;Please input a number between 1 and 9: &quot;;
		cin &gt;&gt; x;
	}	while (x &lt; 1 || x &gt; 9);

	int anArray[9] = {4, 6, 7, 3, 8, 2, 1, 9, 5};
	for (int iii = 0; iii &lt; 9; iii++)
		cout &lt;&lt; anArray[iii] &lt;&lt; &quot; &quot;;

	cout &lt;&lt; endl;

	for (int jjj = 0; jjj &lt; 9; jjj++)
	{
		if (anArray[jjj] == x)
		{
			cout &lt;&lt; &quot;The number you entered (&quot; &lt;&lt; x &lt;&lt; &quot;) has index number: &quot; &lt;&lt; jjj &lt;&lt; endl;
			break;
		}
	}

	return 0;
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sagar</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-74973</link>
		<dc:creator>Sagar</dc:creator>
		<pubDate>Sun, 27 Dec 2009 23:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-74973</guid>
		<description>&lt;pre&gt; In solution number 2, shouldn&#039;t it be nNumber &gt; 1 &#124;&#124; nNumber &lt; 9 ?</description>
		<content:encoded><![CDATA[<pre> In solution number 2, shouldn't it be nNumber &gt; 1 || nNumber &lt; 9 ?</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-72926</link>
		<dc:creator>Mattias</dc:creator>
		<pubDate>Tue, 24 Nov 2009 16:26:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-72926</guid>
		<description>For the second question, would this also work? (When each element in the array has a unique value of course)
If it has any downsides please let me know. 

&lt;pre&gt;
#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;


int main()
{
	using namespace std;
	int nInputNumber;
	do
	{
		cout &lt;&lt; &quot;Please enter a number between 1 and 9: &quot;;
		cin &gt;&gt; nInputNumber;
	}while((nInputNumber &lt; 0) &#124;&#124; (nInputNumber &gt;= 9));
	
	const int nArrayElements = 9;
	int anArray[nArrayElements] = { 4, 6, 7, 3, 8, 2, 1, 9, 5 };
	cout &lt;&lt;&quot;The array contains the following elements: &quot;;
	int nInputElement = -1;  // This will hold the place of the input number.
	for(int iii = 0; iii &lt; 9; iii++)
	{
		cout &lt;&lt; anArray[iii] &lt;&lt; &quot; &quot;;
		if(anArray[iii] == nInputNumber)
			nInputElement = iii+1;
	}
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Your number was element number &quot; &lt;&lt; nInputElement &lt;&lt; &quot;.&quot; &lt;&lt; endl;
	return 0;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>For the second question, would this also work? (When each element in the array has a unique value of course)<br />
If it has any downsides please let me know. </p>
<pre>
#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;

int main()
{
	using namespace std;
	int nInputNumber;
	do
	{
		cout &lt;&lt; &quot;Please enter a number between 1 and 9: &quot;;
		cin &gt;&gt; nInputNumber;
	}while((nInputNumber &lt; 0) || (nInputNumber &gt;= 9));

	const int nArrayElements = 9;
	int anArray[nArrayElements] = { 4, 6, 7, 3, 8, 2, 1, 9, 5 };
	cout &lt;&lt;&quot;The array contains the following elements: &quot;;
	int nInputElement = -1;  // This will hold the place of the input number.
	for(int iii = 0; iii &lt; 9; iii++)
	{
		cout &lt;&lt; anArray[iii] &lt;&lt; &quot; &quot;;
		if(anArray[iii] == nInputNumber)
			nInputElement = iii+1;
	}
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Your number was element number &quot; &lt;&lt; nInputElement &lt;&lt; &quot;.&quot; &lt;&lt; endl;
	return 0;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: tnemmoC</title>
		<link>http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/comment-page-1/#comment-67653</link>
		<dc:creator>tnemmoC</dc:creator>
		<pubDate>Wed, 02 Sep 2009 19:57:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/63-arrays-and-loops/#comment-67653</guid>
		<description>I&#039;ve also noticed it happens when the input is above around 2 * 10^10 ... it kinda bothers me. Why doesn&#039;t it wrap around or something?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve also noticed it happens when the input is above around 2 * 10^10 &#8230; it kinda bothers me. Why doesn&#8217;t it wrap around or something?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

