<?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>what is switch in c programming - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/what-is-switch-in-c-programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/what-is-switch-in-c-programming/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 03 Oct 2022 07:00:53 +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>what is switch in c programming - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/what-is-switch-in-c-programming/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is Switch Statement in C with example ?</title>
		<link>https://www.wikitechy.com/interview-questions/c/what-is-switch-statement-in-c-with-example/</link>
					<comments>https://www.wikitechy.com/interview-questions/c/what-is-switch-statement-in-c-with-example/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Mon, 03 Oct 2022 06:56:02 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[c switch statement]]></category>
		<category><![CDATA[example of switch statement]]></category>
		<category><![CDATA[switch case example in c]]></category>
		<category><![CDATA[switch case in c]]></category>
		<category><![CDATA[switch case in c programming examples]]></category>
		<category><![CDATA[switch case in c programming questions]]></category>
		<category><![CDATA[switch statement in c++]]></category>
		<category><![CDATA[switch statement with examples]]></category>
		<category><![CDATA[switch--case in c programming]]></category>
		<category><![CDATA[syntax of switch statement]]></category>
		<category><![CDATA[what is switch in c language]]></category>
		<category><![CDATA[what is switch in c programming]]></category>
		<category><![CDATA[what is switch statement in c]]></category>
		<category><![CDATA[what is switch statement in c programming]]></category>
		<category><![CDATA[what is switch statement in c with example]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4911</guid>

					<description><![CDATA[Switch statement is an alternative to if else ladder statement which allows us to execute multiple operations for different values. We can define various statement in multiple cases for different values of single variable. Rules for switch statement Switch expression should be an integer or character data type. Case value must be an integer or [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul style="text-align: justify;">
<li style="text-align: justify;">Switch statement is an alternative to if else ladder statement which allows us to execute multiple operations for different values.</li>
<li>We can define various statement in multiple cases for different values of single variable.</li>
</ul>
<h2 id="rules-for-switch-statement" style="text-align: justify;">Rules for switch statement</h2>
<ul style="text-align: justify;">
<li>Switch expression should be an integer or character data type.</li>
<li>Case value must be an integer or constant value.</li>
<li>We can use only case value inside the switch statement.</li>
<li>Break statement is not mandatory in switch. It is optional.</li>
<li>If a program does not find a break statement in switch expression, all the cases in the switch will be executed along with the matched case.</li>
</ul>
<h2 id="syntax-for-switch-statement" style="text-align: justify;">Syntax for switch statement</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">switch(expression){    <br/>case value1:    <br/>//code to be executed;    <br/>break;  //optional  <br/>case value2:    <br/>//code to be executed;    <br/>break;  //optional  <br/>......    <br/>default:     <br/>code to be executed if all cases are not matched;    <br/>}    </code></pre> </div>
<h2 id="flow-chart-for-switch">Flow chart for switch</h2>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4913 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-statement-in-c.png" alt="" width="730" height="590" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-statement-in-c.png 730w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-statement-in-c-300x242.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-statement-in-c-390x315.png 390w" sizes="(max-width: 730px) 100vw, 730px" /></p>
<h2 id="sample-program">Sample Program</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">    #include&lt;stdio.h&gt;<br/><br/>    int main() {<br/>      int number = 0;<br/>      printf(&quot;enter a number:&quot;);<br/>      scanf(&quot;%d&quot;, &amp; number);<br/>      switch (number) {<br/>      case 10:<br/>        printf(&quot;number is equals to 10&quot;);<br/>        break;<br/>      case 50:<br/>        printf(&quot;number is equal to 50&quot;);<br/>        break;<br/>      case 100:<br/>        printf(&quot;number is equal to 100&quot;);<br/>        break;<br/>      default:<br/>        printf(&quot;number is not equal to 10, 50 or 100&quot;);<br/>      }<br/>      return 0;<br/>    }</code></pre> </div>
<h2 id="output">Output</h2>
<p><img decoding="async" class="alignnone size-full wp-image-4916 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-case-examples.jpg" alt="" width="329" height="182" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-case-examples.jpg 329w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2022/10/switch-case-examples-300x166.jpg 300w" sizes="(max-width: 329px) 100vw, 329px" /></p>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/c/what-is-switch-statement-in-c-with-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
