A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C_Tutorial%2FFunction%2FFunction_Parameter</id>
		<title>C Tutorial/Function/Function Parameter - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C_Tutorial%2FFunction%2FFunction_Parameter"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C_Tutorial/Function/Function_Parameter&amp;action=history"/>
		<updated>2026-04-17T19:12:35Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C_Tutorial/Function/Function_Parameter&amp;diff=3376&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C_Tutorial/Function/Function_Parameter&amp;diff=3376&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C_Tutorial/Function/Function_Parameter&amp;diff=3377&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C_Tutorial/Function/Function_Parameter&amp;diff=3377&amp;oldid=prev"/>
				<updated>2010-05-25T10:32:13Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Call by reference==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
main ( )&lt;br /&gt;
{&lt;br /&gt;
    int i;&lt;br /&gt;
    i = 0;&lt;br /&gt;
    printf (&amp;quot; The value of i before call %d \n&amp;quot;, i);&lt;br /&gt;
    f1 (&amp;amp;i);&lt;br /&gt;
    printf (&amp;quot; The value of i after call %d \n&amp;quot;, i);&lt;br /&gt;
}&lt;br /&gt;
 f1(int *k)&lt;br /&gt;
{&lt;br /&gt;
    *k = *k + 10;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The value of i before call 0&lt;br /&gt;
 The value of i after call 10&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Cube a variable using call-by-reference with a pointer argument==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
void cubeByReference( int *nPtr );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int number = 5;&lt;br /&gt;
   printf( &amp;quot;The original value of number is %d&amp;quot;, number );&lt;br /&gt;
 &lt;br /&gt;
   cubeByReference( &amp;amp;number );&lt;br /&gt;
   printf( &amp;quot;\nThe new value of number is %d\n&amp;quot;, number );&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void cubeByReference( int *nPtr )&lt;br /&gt;
{&lt;br /&gt;
   *nPtr = *nPtr * *nPtr * *nPtr;  /* cube *nPtr */&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The original value of number is 5&lt;br /&gt;
The new value of number is 125&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Cube a variable using call-by-value==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int cubeByValue( int n );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int number = 5; &lt;br /&gt;
   printf( &amp;quot;The original value of number is %d&amp;quot;, number );&lt;br /&gt;
   &lt;br /&gt;
   /* pass number by value to cubeByValue */&lt;br /&gt;
   number = cubeByValue( number );&lt;br /&gt;
   printf( &amp;quot;\nThe new value of number is %d\n&amp;quot;, number );&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
int cubeByValue( int n ) {&lt;br /&gt;
   return n * n * n;   &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The original value of number is 5&lt;br /&gt;
The new value of number is 125&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameter passing==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Information can be passed into function.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
main ( )&lt;br /&gt;
{&lt;br /&gt;
    int i;&lt;br /&gt;
    i = 0;&lt;br /&gt;
    printf (&amp;quot; The value of i before call %d \n&amp;quot;, i);&lt;br /&gt;
    f1 (i);&lt;br /&gt;
    printf (&amp;quot; The value of i after call %d \n&amp;quot;, i);&lt;br /&gt;
}&lt;br /&gt;
f1 (int k)&lt;br /&gt;
{&lt;br /&gt;
    k = k + 10;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The value of i before call 0&lt;br /&gt;
 The value of i after call 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pass variables to function==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
float average(float x, float y)&lt;br /&gt;
{&lt;br /&gt;
  return (x + y)/2.0f;&lt;br /&gt;
}&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  float value1 = 1.0F;&lt;br /&gt;
  float value2 = 2.0F;&lt;br /&gt;
  float value3 = 0.0F;&lt;br /&gt;
&lt;br /&gt;
  value3 = average(value1, value2);&lt;br /&gt;
  printf(&amp;quot;\nThe average is: %f\n&amp;quot;,  value3);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The average is: 1.500000&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use pointer as function parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int change(int* pnumber);              /* Function prototype              */&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  int number = 10;&lt;br /&gt;
  int *pnumber = &amp;amp;number;&lt;br /&gt;
  int result = 0;        &lt;br /&gt;
  result = change(pnumber);&lt;br /&gt;
  printf(&amp;quot;\nIn main, result = %d\tnumber = %d&amp;quot;, result, number);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
int change(int *pnumber)&lt;br /&gt;
{&lt;br /&gt;
  *pnumber *= 2;&lt;br /&gt;
  printf(&amp;quot;\nIn function change, *pnumber = %d\n&amp;quot;, *pnumber );&lt;br /&gt;
  return *pnumber;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;In function change, *pnumber = 20&lt;br /&gt;
     &lt;br /&gt;
     In main, result = 20    number = 20&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>