<?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>changing an array element | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/changing-an-array-element/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 29 Dec 2022 13:59:58 +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>Array Operations</title>
		<link>https://studentprojects.in/software-development/cpp/array-operations-2/</link>
					<comments>https://studentprojects.in/software-development/cpp/array-operations-2/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Sat, 31 Dec 2022 01:55:00 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Accessing an array element]]></category>
		<category><![CDATA[array operations]]></category>
		<category><![CDATA[changing an array element]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=10053</guid>

					<description><![CDATA[<p>Defining an array 1. Without specifying the size of the array: Although the array cannot be left empty in this scenario, we can leave the square brackets empty. It must contain elements. 2. With specifying the size of the array: Accessing an array element An array element can be easily retrieved by its index number.</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/array-operations-2/">Array Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Defining an array</p>



<h4>1. Without specifying the size of the array:</h4>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">int arr[] = {1, 2, 3};</code></pre>



<p>Although the array cannot be left empty in this scenario, we can leave the square brackets empty. It must contain elements.</p>



<h4>2. With specifying the size of the array:</h4>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">int arr[3];
arr[0] = 1, arr[1] = 2, arr[2] = 3;</code></pre>



<h3>Accessing an array element</h3>



<p>An array element can be easily retrieved by its index number.</p>



<p>An index number is a sort of number that allows us to access array variables. In a programme, index numbers provide a way to retrieve each element of an array. It should be noted that the index number begins with 0 and not one.</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
int main()
{
    int arr[] = {1, 2, 3};
    cout &lt;&lt; arr[1] &lt;&lt; endl;
}
</code></pre>



<p>Output:</p>



<p>2</p>



<h3>Changing an array element</h3>



<p>An element in an array can be overwritten using its index number.</p>



<p>Example:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
int main()
{
    int arr[] = {1, 2, 3};
    arr[2] = 8; //changing the element on index 2
    cout &lt;&lt; arr[2] &lt;&lt; endl;
}
</code></pre>



<p>Output:</p>



<p>8</p><p>The post <a href="https://studentprojects.in/software-development/cpp/array-operations-2/">Array Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/array-operations-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
