<?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 variable | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/local-variable/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 16 Feb 2023 07:28:41 +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>Variables in Java-Part I</title>
		<link>https://studentprojects.in/software-development/java/variables-in-java-part-i/</link>
					<comments>https://studentprojects.in/software-development/java/variables-in-java-part-i/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Wed, 22 Feb 2023 07:24:44 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[local variable]]></category>
		<category><![CDATA[Variables in java]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=10198</guid>

					<description><![CDATA[<p>Information can be stored in variables, which the programmer can then change and refer to later in the code. The data type of a Java variable can provide information about the size and organisation of the variable&#8217;s memory. Syntax: There are three types of variables in java: A variable declared within the body of a</p>
<p>The post <a href="https://studentprojects.in/software-development/java/variables-in-java-part-i/">Variables in Java-Part I</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Information can be stored in variables, which the programmer can then change and refer to later in the code. The data type of a Java variable can provide information about the size and organisation of the variable&#8217;s memory.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">datatype variable = value</code></pre>



<p>There are three types of variables in java:</p>



<ol>
<li>Local variable</li>



<li>Instance variable</li>



<li>Class/Static variable</li>
</ol>



<ol type="A">
<li><strong>Local Variables:</strong></li>
</ol>



<p>A variable declared within the body of a method or constructor is referred to as a local variable. This is because the scope of a local variable is limited to the method or constructor in which it is defined, and it cannot be accessed by other methods in the class.To declare a local variable within the method body, the &#8220;static&#8221; keyword is used.</p>



<p>For example:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">public class variableType {
    public void localVariable() {
        String name = "Ben";
        int marks = 95;
        System.out.println(name + " Scored " + marks + "%.");
    }

    public static void main(String[] args) {
        variableType vt = new variableType();
        vt.localVariable();
    }
}</code></pre>



<p>Output:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">Ben Scored 95%.</code></pre>



<p>If an attempt is made to access a local variable outside the method or constructor in which it was created, it will result in an error.</p>



<p>For example:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">public class variableType {
    public void localVariable() {
        String name = "Ben";
        int marks = 95;
    }
    public void notLocalVariable() {
        System.out.println(name + " Scored " + marks + "%.");
    }

    public static void main(String[] args) {
        variableType vt = new variableType();
        vt.notLocalVariable();
    }
}</code></pre>



<p>Output:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">name cannot be resolved to a variable
marks cannot be resolved to a variable</code></pre><p>The post <a href="https://studentprojects.in/software-development/java/variables-in-java-part-i/">Variables in Java-Part I</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/java/variables-in-java-part-i/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Static Variables</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Tue, 25 Oct 2022 09:04:59 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[local variable]]></category>
		<category><![CDATA[c static variable]]></category>
		<category><![CDATA[worldwide variable]]></category>
		<category><![CDATA[static variable]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9711</guid>

					<description><![CDATA[<p>A.Local Variables Variables declared within a function or a block of code are referred to as local variables. These variables are only accessible within the function in which they were declared. Local variables have a function-specific scope since they can only be accessed by statements that are included within that function or code block. B.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/">C Static Variables</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>A.Local Variables</strong></p>



<ul><li>Variables declared within a function or a block of code are referred to as local variables. These variables are only accessible within the function in which they were declared. Local variables have a function-specific scope since they can only be accessed by statements that are included within that function or code block.</li></ul>



<p><strong>B. Worldwide Variables</strong></p>



<ul><li>Global variables are those that have definitions separate from any and all functions. We can access global variables within any of the program&#8217;s declared functions to retrieve their values. The system initialises global variables when they are defined. When a name is defined for both local and global variables, the local variable is given preference.</li></ul>



<p><strong>C. Static Variables</strong></p>



<ul><li>One definition of a static variable is one that keeps its value even after the programme leaves the scope in which it was declared. Static variables don&#8217;t need to be initialised afresh in the new scope; they keep their value. Static variables retain their memory until the program&#8217;s end, but regular variables are deleted when the function they were declared in is exited. Both inside and outside of the function they can be declared. The block is the local area for static variables. A static variable&#8217;s default value is zero. A static variable is declared with the word static.</li></ul>



<p><strong>Output:</strong></p>



<p>static datatype variable_name = variable_value;</p>



<p>Static global variables differ from static local variables.</p>



<p><strong>Static global variable</strong></p>



<ul><li>Static global variables are any variables with the static keyword specified outside of a function. Any method in the application will allow access to this variable.</li></ul>



<p><strong>Static local variable</strong></p>



<ul><li>Static local variables are any variables that are declared with the static keyword inside of a function. A static local variable has the same scope as a local variable, but its memory is accessible for the duration of the program&#8217;s execution.</li></ul>



<p><strong>The characteristics of static variables</strong></p>



<ul><li>A static variable&#8217;s value will remain after the programme leaves the scope in which it was declared.</li><li>A static variable&#8217;s allotted memory is accessible for the duration of the program&#8217;s execution.</li><li>A static variable&#8217;s default value is 0 if we don&#8217;t initialise it.</li></ul><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/">C Static Variables</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Golbal and local variable</title>
		<link>https://studentprojects.in/software-development/golbal-and-local-variable/</link>
					<comments>https://studentprojects.in/software-development/golbal-and-local-variable/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Wed, 28 Sep 2022 16:52:56 +0000</pubDate>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Golbal]]></category>
		<category><![CDATA[local variable]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9611</guid>

					<description><![CDATA[<p>Local Variable: A local variable is a variable that is declared inside of a function or loop. When we define a variable within a function, its scope is limited to the function. This is the case with functions. From the time it is defined until the function&#8217;s conclusion, it is accessible. It will endure while</p>
<p>The post <a href="https://studentprojects.in/software-development/golbal-and-local-variable/">Golbal and local variable</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Local Variable:</p>



<p>A local variable is a variable that is declared inside of a function or loop. When we define a variable within a function, its scope is limited to the function. This is the case with functions. From the time it is defined until the function&#8217;s conclusion, it is accessible. It will endure while the function is running. Access to local variables from outside the function is prohibited. The function&#8217;s parameter names have the same behavior as local variables.</p>



<p>Example:</p>



<p>def sum():</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a=10 #local variable cannot be accessed outside the function</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b=20</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum=a+b</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print( sum)</p>



<p>print(a) #this gives an error</p>



<p>It will give you an error if you attempt to access variable &#8220;a&#8221; outside of the function. It can only be accessed within the function.</p>



<p>Globe variable:</p>



<p>A global variable, on the other hand, is simpler to comprehend because it is accessible throughout the program and is not specified inside the function. It can alternatively be described as a variable that is defined in the program&#8217;s main body. Any loop or function may call it. Anywhere in the software is within its scope.</p>



<p>Example:</p>



<p>a=1&nbsp; #global variable</p>



<p>def print_Number():</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a=a+1;</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(a)</p>



<p>&nbsp;print_number()</p>



<p>This is due to the fact that we can only access the global variable; inside the function, we are unable to change it.</p>



<p>The global keyword in Python enables us to change the global variable. It is employed to establish a global variable and make local changes to the variable.</p>



<p>Rules of the global keyword:</p>



<p>Unless specifically designated as global, any value we assigned to a variable within the body of a function would be considered local Implicitly global variables are those that are exclusively used inside of functions. The global keyword shouldn&#8217;t be used outside of functions.</p><p>The post <a href="https://studentprojects.in/software-development/golbal-and-local-variable/">Golbal and local variable</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/golbal-and-local-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
