<?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: 1.4 &#8212; A first look at functions</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/</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: Frostworld</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96850</link>
		<dc:creator>Frostworld</dc:creator>
		<pubDate>Mon, 16 Jan 2012 11:04:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96850</guid>
		<description>You didn&#039;t use a function.

int doubleNumber(int x)
{
    return 2*x;
}

int main()
{
  int num;
  scanf(&quot;%d&quot;,&amp;num);
  printf(&quot;%d&quot;,doubleNumber(num));
  return 0;
}</description>
		<content:encoded><![CDATA[<p>You didn&#8217;t use a function.</p>
<p>int doubleNumber(int x)<br />
{<br />
    return 2*x;<br />
}</p>
<p>int main()<br />
{<br />
  int num;<br />
  scanf(&#8220;%d&#8221;,&amp;num);<br />
  printf(&#8220;%d&#8221;,doubleNumber(num));<br />
  return 0;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris646</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96814</link>
		<dc:creator>Chris646</dc:creator>
		<pubDate>Wed, 11 Jan 2012 01:41:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96814</guid>
		<description>sorry for posting that twice i didnt notice it actually worked the first time</description>
		<content:encoded><![CDATA[<p>sorry for posting that twice i didnt notice it actually worked the first time</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris646</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96813</link>
		<dc:creator>Chris646</dc:creator>
		<pubDate>Wed, 11 Jan 2012 01:38:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96813</guid>
		<description>&lt;pre&gt;Hi i tried to make to make a program where it says enter x for this equation 5x + 3 then you enter a number using cin and then it says You entered &quot;x&quot;. Then it says the answer to the equation with the &quot;x&quot; you enetred. I keep getting build errors though. Im using viusal studios. Here is what I wrote for the code:
// EquationNumberEnter.cpp : Defines the entry point for the application.
//

#include &quot;stdafx.h&quot;

#include &lt;iostream&gt;

int Main()
{
	using namespace std;
	cout &lt;&lt; &quot;Enter x for 5x + 3 &quot;;
	int x;
	cin &gt;&gt; x;
	cout &lt;&lt; &quot;You Entered &quot; &lt;&lt; x &lt;&lt; endl;
	equation();
	return 0;
}

int multiply(int a, int b)
{
	return a * b;
}

int add(int w, int y)
{
	return w + y;
}

int equation()
{
	using namespace std;
	cout &lt;&lt; add(3, multiply(5, x)) &lt;&lt; endl;
}




Please tell me what I did wrong&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>Hi i tried to make to make a program where it says enter x for this equation 5x + 3 then you enter a number using cin and then it says You entered &quot;x&quot;. Then it says the answer to the equation with the &quot;x&quot; you enetred. I keep getting build errors though. Im using viusal studios. Here is what I wrote for the code:
// EquationNumberEnter.cpp : Defines the entry point for the application.
//

#include &quot;stdafx.h&quot;

#include &lt;iostream&gt;

int Main()
{
	using namespace std;
	cout &lt;&lt; &quot;Enter x for 5x + 3 &quot;;
	int x;
	cin &gt;&gt; x;
	cout &lt;&lt; &quot;You Entered &quot; &lt;&lt; x &lt;&lt; endl;
	equation();
	return 0;
}

int multiply(int a, int b)
{
	return a * b;
}

int add(int w, int y)
{
	return w + y;
}

int equation()
{
	using namespace std;
	cout &lt;&lt; add(3, multiply(5, x)) &lt;&lt; endl;
}

Please tell me what I did wrong</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris646</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96808</link>
		<dc:creator>Chris646</dc:creator>
		<pubDate>Tue, 10 Jan 2012 02:42:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96808</guid>
		<description>Hey so i was trying to write this program where it says enter x for this equation and then you enter x and then it says you entered &quot;x&quot; and then it shows you the answer to the equation. I keep getting build errors though. Im using visual studios. Here is what i wrote for the program:

// EquationNumberEnter.cpp : Defines the entry point for the application.
//

#include &quot;stdafx.h&quot;

#include 

int Main()
{
	using namespace std;
	cout &lt;&gt; x;
	cout &lt;&lt; &quot;You Entered &quot; &lt;&lt; x &lt;&lt; endl;
	equation();
	return 0;
}

int multiply(int a, int b)
{
	return a * b;
}

int add(int w, int y)
{
	return w + y;
}

int equation()
{
	using namespace std;
	cout &lt;&lt; (5, multiply x) add 3 &lt;&lt; endl;
}

Please tell me what I did wrong</description>
		<content:encoded><![CDATA[<p>Hey so i was trying to write this program where it says enter x for this equation and then you enter x and then it says you entered &#8220;x&#8221; and then it shows you the answer to the equation. I keep getting build errors though. Im using visual studios. Here is what i wrote for the program:</p>
<p>// EquationNumberEnter.cpp : Defines the entry point for the application.<br />
//</p>
<p>#include &#8220;stdafx.h&#8221;</p>
<p>#include </p>
<p>int Main()<br />
{<br />
	using namespace std;<br />
	cout &lt;&gt; x;<br />
	cout &lt;&lt; &quot;You Entered &quot; &lt;&lt; x &lt;&lt; endl;<br />
	equation();<br />
	return 0;<br />
}</p>
<p>int multiply(int a, int b)<br />
{<br />
	return a * b;<br />
}</p>
<p>int add(int w, int y)<br />
{<br />
	return w + y;<br />
}</p>
<p>int equation()<br />
{<br />
	using namespace std;<br />
	cout &lt;&lt; (5, multiply x) add 3 &lt;&lt; endl;<br />
}</p>
<p>Please tell me what I did wrong</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xPrezidential</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96787</link>
		<dc:creator>xPrezidential</dc:creator>
		<pubDate>Tue, 03 Jan 2012 23:41:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96787</guid>
		<description>Here&#039;s my code for quiz 4 and 5. Give me feedback on it, please. I just began C++ today.

---------------------------------------
#include &quot;stdafx.h&quot;
#include 

int doubleNumber( int x )
{
	return x * 2;
}

int main( )
{
	int integerToDouble = -1,
		theResult = -1;

	using namespace std;
	cout &lt;&gt; integerToDouble;
	cout &lt;&lt; endl;

	theResult = doubleNumber( integerToDouble );

	cout &lt;&lt; &quot;The doubled value of &quot; &lt;&lt; integerToDouble &lt;&lt; &quot; is &quot; &lt;&lt; theResult &lt;&lt; &quot;.&quot; &lt;&lt; endl;

	system( &quot;PAUSE&quot; );
	return 0;</description>
		<content:encoded><![CDATA[<p>Here&#8217;s my code for quiz 4 and 5. Give me feedback on it, please. I just began C++ today.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
#include &#8220;stdafx.h&#8221;<br />
#include </p>
<p>int doubleNumber( int x )<br />
{<br />
	return x * 2;<br />
}</p>
<p>int main( )<br />
{<br />
	int integerToDouble = -1,<br />
		theResult = -1;</p>
<p>	using namespace std;<br />
	cout &lt;&gt; integerToDouble;<br />
	cout &lt;&lt; endl;</p>
<p>	theResult = doubleNumber( integerToDouble );</p>
<p>	cout &lt;&lt; &quot;The doubled value of &quot; &lt;&lt; integerToDouble &lt;&lt; &quot; is &quot; &lt;&lt; theResult &lt;&lt; &quot;.&quot; &lt;&lt; endl;</p>
<p>	system( &quot;PAUSE&quot; );<br />
	return 0;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sjm71</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96721</link>
		<dc:creator>sjm71</dc:creator>
		<pubDate>Thu, 22 Dec 2011 11:38:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96721</guid>
		<description>Yes, this is always the case. You can also use function prototypes before “main()” instead of writing the full funtion definitions and the write the funtion definitions after “main()”…

#include 

//Function prototypes…
int add(int, int); // NOTE: the semicolon (;) at the end!

int main()
{
…
return 0;
}

int add(int x, int y)
{
return x + y;
}

Hope this helps?</description>
		<content:encoded><![CDATA[<p>Yes, this is always the case. You can also use function prototypes before “main()” instead of writing the full funtion definitions and the write the funtion definitions after “main()”…</p>
<p>#include </p>
<p>//Function prototypes…<br />
int add(int, int); // NOTE: the semicolon (;) at the end!</p>
<p>int main()<br />
{<br />
…<br />
return 0;<br />
}</p>
<p>int add(int x, int y)<br />
{<br />
return x + y;<br />
}</p>
<p>Hope this helps?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sjm71</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96720</link>
		<dc:creator>sjm71</dc:creator>
		<pubDate>Thu, 22 Dec 2011 11:27:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96720</guid>
		<description>Yes, this is always the case. You can also use function prototypes before &quot;main()&quot; instead of writing the full funtion definitions and the write the funtion definitions after &quot;main()&quot;...

#include 

//Function prototypes...
int add(int, int);  // NOTE: the semicolon (;) at the end!

int main()
{
   ...
   return 0;
}

int add(int x, int y)
{
   return x + y;
}

Hope this helps?</description>
		<content:encoded><![CDATA[<p>Yes, this is always the case. You can also use function prototypes before &#8220;main()&#8221; instead of writing the full funtion definitions and the write the funtion definitions after &#8220;main()&#8221;&#8230;</p>
<p>#include </p>
<p>//Function prototypes&#8230;<br />
int add(int, int);  // NOTE: the semicolon (;) at the end!</p>
<p>int main()<br />
{<br />
   &#8230;<br />
   return 0;<br />
}</p>
<p>int add(int x, int y)<br />
{<br />
   return x + y;<br />
}</p>
<p>Hope this helps?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brandon broadwater</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96521</link>
		<dc:creator>brandon broadwater</dc:creator>
		<pubDate>Thu, 01 Dec 2011 02:10:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96521</guid>
		<description>the reason that you cant use the statement &quot;void&quot; for the main function, is because in the main function, you have to return an integer. you know how you have to return 0; at the end of the main function? that just means you should have no errors. but anyway, 0 is an integer, and thats why you always have to use &quot;int&quot;.</description>
		<content:encoded><![CDATA[<p>the reason that you cant use the statement &#8220;void&#8221; for the main function, is because in the main function, you have to return an integer. you know how you have to return 0; at the end of the main function? that just means you should have no errors. but anyway, 0 is an integer, and thats why you always have to use &#8220;int&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grif</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-96478</link>
		<dc:creator>Grif</dc:creator>
		<pubDate>Sun, 27 Nov 2011 04:56:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-96478</guid>
		<description>Very much a beginner here, but there&#039;s something I need a little clarification with - switching the order of &quot;main()&quot; and &quot;add(x, y)&quot; in the code seems to cause an error (I was trying to input it that way due to my own OCD wanting main to be up the top of the code). 

The result seemed to be that &quot;main()&quot; had no idea that &quot;add(x, y)&quot; even existed unless &quot;add(x, y)&quot; was assigned/created in code *before* &quot;main()&quot;.

Is this always the case? That &quot;function a&quot; trying to call &quot;function b&quot; requires function b to be defined (and placed literally above function a&#039;s code in the editor) before it&#039;s run?</description>
		<content:encoded><![CDATA[<p>Very much a beginner here, but there&#8217;s something I need a little clarification with &#8211; switching the order of &#8220;main()&#8221; and &#8220;add(x, y)&#8221; in the code seems to cause an error (I was trying to input it that way due to my own OCD wanting main to be up the top of the code). </p>
<p>The result seemed to be that &#8220;main()&#8221; had no idea that &#8220;add(x, y)&#8221; even existed unless &#8220;add(x, y)&#8221; was assigned/created in code *before* &#8220;main()&#8221;.</p>
<p>Is this always the case? That &#8220;function a&#8221; trying to call &#8220;function b&#8221; requires function b to be defined (and placed literally above function a&#8217;s code in the editor) before it&#8217;s run?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Da-Rage44</title>
		<link>http://www.learncpp.com/cpp-tutorial/14-a-first-look-at-functions/comment-page-3/#comment-95919</link>
		<dc:creator>Da-Rage44</dc:creator>
		<pubDate>Tue, 23 Aug 2011 06:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=23#comment-95919</guid>
		<description>You have a backwards &quot;&lt;&quot; for one, that and you have no tags on  also even if you fix the &quot;&lt;&quot; &quot;cout &lt;&lt; x;&quot;  still leaves x as an unidentified integer. Your function also has no return value. Here is your code fixed.
#include &quot;stdafx.h&quot;
#include 


void DoPrint() {
	using namespace std;  // we need this in each function that uses cout and endl
	cout &lt;&lt; &quot;In DoPrint()&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;nice to meet you!&quot; &lt;&lt; endl;

}

int main2 () 
{
	using namespace std;
	int x = 4;
	cout &lt;&lt; &quot;print and main both are crazy if this works&quot; &lt;&lt; endl;
	cout &lt;&lt; x; // same

	return 0;
	}

int main () {
	using namespace std;
	cout &lt;&lt; &quot;Starting main()&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Hello world!&quot; &lt;&lt; endl; //standard hellow world intro, 1.1
	DoPrint(); // This is a function call to DoPrint()
	main2();
	cout &lt;&lt; &quot;Ending main()&quot; &lt;&lt; endl;

	return 0;

}
X has been defined and your int main2() function has a return value.</description>
		<content:encoded><![CDATA[<p>You have a backwards &#8220;&lt;&quot; for one, that and you have no tags on  also even if you fix the &#8220;&lt;&quot; &quot;cout &lt;&lt; x;&quot;  still leaves x as an unidentified integer. Your function also has no return value. Here is your code fixed.<br />
#include &quot;stdafx.h&quot;<br />
#include </p>
<p>void DoPrint() {<br />
	using namespace std;  // we need this in each function that uses cout and endl<br />
	cout &lt;&lt; &quot;In DoPrint()&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;nice to meet you!&quot; &lt;&lt; endl;</p>
<p>}</p>
<p>int main2 ()<br />
{<br />
	using namespace std;<br />
	int x = 4;<br />
	cout &lt;&lt; &quot;print and main both are crazy if this works&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; x; // same</p>
<p>	return 0;<br />
	}</p>
<p>int main () {<br />
	using namespace std;<br />
	cout &lt;&lt; &quot;Starting main()&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Hello world!&quot; &lt;&lt; endl; //standard hellow world intro, 1.1<br />
	DoPrint(); // This is a function call to DoPrint()<br />
	main2();<br />
	cout &lt;&lt; &quot;Ending main()&quot; &lt;&lt; endl;</p>
<p>	return 0;</p>
<p>}<br />
X has been defined and your int main2() function has a return value.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

