<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>call by pointer in c++ | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/call-by-pointer-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Wed, 28 Dec 2022 15:32:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Methods of function-Part I</title>
		<link>https://studentprojects.in/software-development/cpp/methods-of-function-part-i/</link>
					<comments>https://studentprojects.in/software-development/cpp/methods-of-function-part-i/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Mon, 09 Jan 2023 15:27:50 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Methods of funtion in c++]]></category>
		<category><![CDATA[call by value in c++]]></category>
		<category><![CDATA[call by pointer in c++]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=10081</guid>

					<description><![CDATA[<p>Now, there are methods using which arguments are sent to the function. They are, 1. Call by Value in C++ In C++, call by value is a way for passing values to function parameters. In the case of call by value, copies of the actual parameters are passed to the formal parameter, therefore changing the</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/methods-of-function-part-i/">Methods of function-Part I</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Now, there are methods using which arguments are sent to the function. They are,</p>



<h3>1. Call by Value in C++</h3>



<p>In C++, call by value is a way for passing values to function parameters. In the case of call by value, copies of the actual parameters are passed to the formal parameter, therefore changing the values within the function has no effect on the actual values.</p>



<p>The call by value method is demonstrated in the following example:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
void swap(int a, int b)
{
    int temp = a;
    a = b;
    b = temp;
}
 
int main()
{
    int x = 5, y = 6;
    cout &lt;&lt; "The value of x is " &lt;&lt; x &lt;&lt; " and the value of y is " &lt;&lt; y &lt;&lt; endl;
    swap(x, y);
    cout &lt;&lt; "The value of x is " &lt;&lt; x &lt;&lt; " and the value of y is " &lt;&lt; y &lt;&lt; endl;
}
</code></pre>



<p>Output:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">The value of x is 5 and the value of y is 6

The value of x is 5 and the value of y is 6</code></pre>



<h3>2.Call by Pointer in C++</h3>



<p>In C++, a pointer call is a way for passing values to function parameters. In the case of a pointer call, the address of the actual parameters is provided to the formal parameter, which means that if we modify the values inside the function, the actual values will change.</p>



<p>Here&#8217;s an example of a call by pointer method in action:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}
 
int main()
{
    int x = 5, y = 6;
    cout &lt;&lt; "The value of x is " &lt;&lt; x &lt;&lt; " and the value of y is " &lt;&lt; y &lt;&lt; endl;
    swap(&amp;x, &amp;y);
    cout &lt;&lt; "The value of x is " &lt;&lt; x &lt;&lt; " and the value of y is " &lt;&lt; y &lt;&lt; endl;
}</code></pre>



<p>Output:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">The value of x is 5 and the value of y is 6
The value of x is 6 and the value of y is 5</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/methods-of-function-part-i/">Methods of function-Part I</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/methods-of-function-part-i/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
