<?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: 5.9 &#8212; Random number generation</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/59-random-number-generation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Sep 2010 10:51:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: THE TERMINATOR</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-89889</link>
		<dc:creator>THE TERMINATOR</dc:creator>
		<pubDate>Sun, 08 Aug 2010 20:53:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-89889</guid>
		<description>HELP!!! MY PRNG KEEPS PRINTING &quot;4 8 15 16 23 42&quot; NO MATTER WHAT I DO!!!!!</description>
		<content:encoded><![CDATA[<p>HELP!!! MY PRNG KEEPS PRINTING &#8220;4 8 15 16 23 42&#8243; NO MATTER WHAT I DO!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack Sparrow II</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-89675</link>
		<dc:creator>Jack Sparrow II</dc:creator>
		<pubDate>Thu, 05 Aug 2010 15:16:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-89675</guid>
		<description>My question is how do I generate random numbers without generating the same ones multiple times?</description>
		<content:encoded><![CDATA[<p>My question is how do I generate random numbers without generating the same ones multiple times?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jjtricky</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-88614</link>
		<dc:creator>Jjtricky</dc:creator>
		<pubDate>Sun, 18 Jul 2010 01:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-88614</guid>
		<description>I really don&#039;t get this line:

&lt;pre&gt; if ((nCount+1) % 5 == 0) &lt;/pre&gt;

Surely, this would break the line after the fourth number, as:
&lt;pre&gt;
nCount=4
(4+1)/5 

5/5 = 1.0
&lt;/pre&gt;

Therefore, the line is ended</description>
		<content:encoded><![CDATA[<p>I really don&#8217;t get this line:</p>
<pre> if ((nCount+1) % 5 == 0) </pre>
<p>Surely, this would break the line after the fourth number, as:</p>
<pre>
nCount=4
(4+1)/5 

5/5 = 1.0
</pre>
<p>Therefore, the line is ended</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gigith</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-86372</link>
		<dc:creator>Gigith</dc:creator>
		<pubDate>Sat, 12 Jun 2010 18:59:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-86372</guid>
		<description>Why is stdafx.h included?
I could understand you breaking GCC/MinGW/Other compatibility if you had to, but it doesn&#039;t look like it even gets used in those examples.</description>
		<content:encoded><![CDATA[<p>Why is stdafx.h included?<br />
I could understand you breaking GCC/MinGW/Other compatibility if you had to, but it doesn&#8217;t look like it even gets used in those examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-85518</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Fri, 28 May 2010 18:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-85518</guid>
		<description>Hi Alex!
I want to start learning C++,and I have an idea of a program,what I want to create. I want to randomize some sentences(for example:you push a button of a program,and it shows a sentence:Welcome to my world!then push again,and shows:How are you?) Is it possible to do with this tutorial?

Hope to hear from you soon!</description>
		<content:encoded><![CDATA[<p>Hi Alex!<br />
I want to start learning C++,and I have an idea of a program,what I want to create. I want to randomize some sentences(for example:you push a button of a program,and it shows a sentence:Welcome to my world!then push again,and shows:How are you?) Is it possible to do with this tutorial?</p>
<p>Hope to hear from you soon!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-84928</link>
		<dc:creator>Nathan</dc:creator>
		<pubDate>Wed, 19 May 2010 02:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-84928</guid>
		<description>&lt;pre&gt;using namespace std;

int nNum;
bool check;

int main()
{
    srand(time(0)); // set initial seed value to system clock
	int nNum = rand();
    cout &lt;&lt; nNum;
	while (check() == false)
	{
		check();
	}
}

bool check()
{
	int nCheck;
	cin &lt;&lt; nCheck;
	if (nCheck == nNum)
	{
		cout &lt;&lt; &quot;Correct!&quot; &lt;&lt; endl; 
		return 1;
	}
	else if (nCheck &lt; nNum)
	{
		cout &lt;&lt; &quot;Too Low.&quot; &lt;&lt; endl; 
		return 0;
	}
	else if (nCheck &gt; nNum)
	{
		cout &lt;&lt; &quot;Too High.&quot; &lt;&lt; endl; 
		return 0;
	}
}
&lt;!--formatted--&gt;&lt;/pre&gt;
Hey I don&#039;t know if anyone could help me but I&#039;m trying to make the game Alex mentioned called Hi-Lo and I get the errors 
&lt;pre&gt;
&quot;main.cpp(15) : error C2064: term does not evaluate to a function taking 0 arguments&quot; 

and 

&quot;main.cpp(15) : fatal error C1903: unable to recover from previous error(s); stopping compilation&quot;&lt;!--formatted--&gt;&lt;/pre&gt;
 Can anyone tell me what I did wrong?</description>
		<content:encoded><![CDATA[<pre>using namespace std;

int nNum;
bool check;

int main()
{
    srand(time(0)); // set initial seed value to system clock
	int nNum = rand();
    cout &lt;&lt; nNum;
	while (check() == false)
	{
		check();
	}
}

bool check()
{
	int nCheck;
	cin &lt;&lt; nCheck;
	if (nCheck == nNum)
	{
		cout &lt;&lt; &quot;Correct!&quot; &lt;&lt; endl;
		return 1;
	}
	else if (nCheck &lt; nNum)
	{
		cout &lt;&lt; &quot;Too Low.&quot; &lt;&lt; endl;
		return 0;
	}
	else if (nCheck &gt; nNum)
	{
		cout &lt;&lt; &quot;Too High.&quot; &lt;&lt; endl;
		return 0;
	}
}
<!--formatted--></pre>
<p>Hey I don&#8217;t know if anyone could help me but I&#8217;m trying to make the game Alex mentioned called Hi-Lo and I get the errors </p>
<pre>
&quot;main.cpp(15) : error C2064: term does not evaluate to a function taking 0 arguments&quot; 

and 

&quot;main.cpp(15) : fatal error C1903: unable to recover from previous error(s); stopping compilation&quot;<!--formatted--></pre>
<p> Can anyone tell me what I did wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shuuuuuu</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-84325</link>
		<dc:creator>Shuuuuuu</dc:creator>
		<pubDate>Sat, 08 May 2010 12:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-84325</guid>
		<description>Alex, you have a v good understanding of the field which you deal with. Thanks for all these detailed tutorials. Keep up the good work. 
Thankyou Alex.</description>
		<content:encoded><![CDATA[<p>Alex, you have a v good understanding of the field which you deal with. Thanks for all these detailed tutorials. Keep up the good work.<br />
Thankyou Alex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-80703</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 16 Mar 2010 21:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-80703</guid>
		<description>You can use ASCII numbers and use static_cast to make them into characters</description>
		<content:encoded><![CDATA[<p>You can use ASCII numbers and use static_cast to make them into characters</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-80695</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 16 Mar 2010 20:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-80695</guid>
		<description>Hi Alex, could you please explain how this works?
&lt;pre&gt;// Generate a random number between nLow and nHigh (inclusive)
unsigned int GetRandomNumber(int nLow, int nHigh)
{
    return (rand() % (nHigh - nLow + 1)) + nLow;
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi Alex, could you please explain how this works?</p>
<pre>// Generate a random number between nLow and nHigh (inclusive)
unsigned int GetRandomNumber(int nLow, int nHigh)
{
    return (rand() % (nHigh - nLow + 1)) + nLow;
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: RAMI</title>
		<link>http://www.learncpp.com/cpp-tutorial/59-random-number-generation/comment-page-1/#comment-78539</link>
		<dc:creator>RAMI</dc:creator>
		<pubDate>Thu, 18 Feb 2010 08:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=218#comment-78539</guid>
		<description>hi when i run my program it give me a random number but when i rerun it agian it give me the same number i want each time i run the program i want it to give me a diffrent number</description>
		<content:encoded><![CDATA[<p>hi when i run my program it give me a random number but when i rerun it agian it give me the same number i want each time i run the program i want it to give me a diffrent number</p>
]]></content:encoded>
	</item>
</channel>
</rss>
