<?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>C++ switch case | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/c-switch-case/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 04:45:21 +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>C++ Switch Case</title>
		<link>https://studentprojects.in/software-development/cpp/c-tutorials-cpp/c-switch-case/</link>
					<comments>https://studentprojects.in/software-development/cpp/c-tutorials-cpp/c-switch-case/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Fri, 16 Dec 2022 08:08:00 +0000</pubDate>
				<category><![CDATA[C++ Tutorials]]></category>
		<category><![CDATA[C++ switch case]]></category>
		<category><![CDATA[expressionafter switch]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9839</guid>

					<description><![CDATA[<p>The control statement that allows us to make an effective selection from a set of options is known as a switch, or a switch case-default, because these three keywords form the control statement. Switch performs the code block that matches the case value. If the value matches none of the cases, the default block is</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/c-tutorials-cpp/c-switch-case/">C++ Switch Case</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>The control statement that allows us to make an effective selection from a set of options is known as a switch, or a switch case-default, because these three keywords form the control statement.</p>



<p>Switch performs the code block that matches the case value. If the value matches none of the cases, the default block is executed.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">switch ( integer/character expression )
{  
case {value 1} :  
do this ;
 
case {value 2} :  
 do this ;  
 
default :  
do this ;
 }
</code></pre>



<p>The expression after the switch can be either an integer or a character expression. Keep in mind that case labels should be unique for each case. If they are the same, it may cause an issue while running a programme. We usually use a colon at the end of the case labels ( : ). Each case is linked to a block. A block is a collection of statements that are grouped together for a specific case.</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 i = 2;
    switch (i)
    {
    case 1:
        cout &lt;&lt; "Statement 1" &lt;&lt; endl;
        break;
 
    case 2:
        cout &lt;&lt; "Statement 2" &lt;&lt; endl;
        break;
 
    default:
        cout &lt;&lt; "Default statement!" &lt;&lt; endl;
    }
}
</code></pre>



<p>Output:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">Statement 2</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/c-tutorials-cpp/c-switch-case/">C++ Switch Case</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/c-tutorials-cpp/c-switch-case/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
