<?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>local and global variables in c - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/local-and-global-variables-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/local-and-global-variables-in-c/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Tue, 16 Aug 2022 11:16:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>local and global variables in c - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/local-and-global-variables-in-c/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are the rules for a local and global variable in Python ?</title>
		<link>https://www.wikitechy.com/interview-questions/python/what-are-the-rules-for-a-local-and-global-variable-in-python/</link>
					<comments>https://www.wikitechy.com/interview-questions/python/what-are-the-rules-for-a-local-and-global-variable-in-python/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Tue, 16 Aug 2022 11:15:33 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[example of global variable in python]]></category>
		<category><![CDATA[global variables python 3]]></category>
		<category><![CDATA[how to change global variable in function python]]></category>
		<category><![CDATA[local and global variables in c]]></category>
		<category><![CDATA[python global variable across modules]]></category>
		<category><![CDATA[python global variable in function]]></category>
		<category><![CDATA[python global variables best practices]]></category>
		<category><![CDATA[what are the rules for a local and global variable in python]]></category>
		<category><![CDATA[what is local variable in python]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4705</guid>

					<description><![CDATA[In python local variables are those which are defined inside a function and its scope is limited to that function only whereas global variables are those which are not defined inside any function and have a global scope. We can say that global variables are accessible throughout the program and inside every function whereas local variables [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In python local variables are those which are defined inside a function and its scope is limited to that function only whereas global variables are those which are not defined inside any function and have a global scope.</li>
<li style="text-align: justify;">We can say that global variables are accessible throughout the program and inside every function whereas local variables are accessible only inside the function in which it was initialized.</li>
</ul>
<h2 id="local-variables" style="text-align: justify;">Local Variables</h2>
<ul>
<li style="text-align: justify;">Inside function local variables are those which are initialized and belongs only to that particular function.</li>
<li style="text-align: justify;">Then it cannot be accessed anywhere outside the function.</li>
</ul>
<h3 id="sample-code" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-python code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-python code-embed-code">def f():<br/>     <br/>    # local variable<br/>    s = &quot;I love Wikitechy&quot;<br/>    print(s)<br/> <br/># Driver code<br/>f()</code></pre> </div>
<h3 id="output" style="text-align: justify;">Output</h3>
<p style="text-align: justify;"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4706" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable.png" alt="" width="969" height="223" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable.png 969w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable-300x69.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable-768x177.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable-390x90.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/local-variable-820x189.png 820w" sizes="(max-width: 969px) 100vw, 969px" /></p>
<h2 id="global-variables" style="text-align: justify;">Global Variables</h2>
<ul style="text-align: justify;">
<li>Outside any function the global variables are those which are defined and which are accessible throughout the program.</li>
</ul>
<h3 id="sample-code-2" style="text-align: justify;">Sample Code</h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-python code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-python code-embed-code"># This function uses global variable s<br/>def f():<br/>    print(&quot;Inside Function&quot;, s)<br/> <br/># Global scope<br/>s = &quot;I love Wikitechy&quot;<br/>f()<br/>print(&quot;Outside Function&quot;, s)</code></pre> </div>
<h3 id="output-2" style="text-align: justify;">Output</h3>
<p style="text-align: justify;"><img decoding="async" class="alignnone size-full wp-image-4707" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable.png" alt="" width="1027" height="255" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable.png 1027w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable-300x74.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable-1024x254.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable-768x191.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable-390x97.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/08/global-variable-820x204.png 820w" sizes="(max-width: 1027px) 100vw, 1027px" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/python/what-are-the-rules-for-a-local-and-global-variable-in-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
