<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: C Tutorial &#8211; The if and switch statement</title>
	<atom:link href="http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement</link>
	<description>CodingUnit is your online resource for learning to program. Tutorials on C, C++, PHP, Python, MySQL, Java, JQuery, Opengl, DirectX and much more!</description>
	<lastBuildDate>Mon, 06 Feb 2012 06:08:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Sean</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-4381</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Fri, 30 Dec 2011 22:03:36 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-4381</guid>
		<description>when using if or else if, can i initialize something instead of printing? (probably a dumb question, but meh)

e.g.
if (number == 1)
    int  identifier = &quot;value1&quot;;
   else if (number == 2)
    int  identifier = &quot;value2&quot;;</description>
		<content:encoded><![CDATA[<p>when using if or else if, can i initialize something instead of printing? (probably a dumb question, but meh)</p>
<p>e.g.<br />
if (number == 1)<br />
    int  identifier = &#8220;value1&#8243;;<br />
   else if (number == 2)<br />
    int  identifier = &#8220;value2&#8243;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Omar</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-3806</link>
		<dc:creator>Omar</dc:creator>
		<pubDate>Fri, 30 Sep 2011 07:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-3806</guid>
		<description>is it possivle to use multiple conditions in switch ..cases! ??
eg if (i7)
how we do this in switch ??</description>
		<content:encoded><![CDATA[<p>is it possivle to use multiple conditions in switch ..cases! ??<br />
eg if (i7)<br />
how we do this in switch ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-3692</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 14 Aug 2011 08:00:19 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-3692</guid>
		<description>@reshma: you are right. Using curly braces in a case statement is a matter of coding style, because most compilers allow different variations. In this case the &lt;strong&gt;b&lt;/strong&gt; statement has multiple printf statements and &lt;strong&gt;a &lt;/strong&gt; has not. Therefore&lt;strong&gt; b&lt;/strong&gt;  has curly braces and &lt;strong&gt;a&lt;/strong&gt; has not. Just as you can do with the if statement, where you use curly braces if there is more than one statement that needs to be run if the if statement is valid. 

You can try it yourself, make little programs and see what is allowed by the compiler. But whatever style you choose (no curly braces, only with multiple statements you use curly braces or always curly braces) try to be consistent, especially if you work with different people on the same code!</description>
		<content:encoded><![CDATA[<p>@reshma: you are right. Using curly braces in a case statement is a matter of coding style, because most compilers allow different variations. In this case the <strong>b</strong> statement has multiple printf statements and <strong>a </strong> has not. Therefore<strong> b</strong>  has curly braces and <strong>a</strong> has not. Just as you can do with the if statement, where you use curly braces if there is more than one statement that needs to be run if the if statement is valid. </p>
<p>You can try it yourself, make little programs and see what is allowed by the compiler. But whatever style you choose (no curly braces, only with multiple statements you use curly braces or always curly braces) try to be consistent, especially if you work with different people on the same code!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: reshma</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-3691</link>
		<dc:creator>reshma</dc:creator>
		<pubDate>Sun, 14 Aug 2011 07:31:24 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-3691</guid>
		<description>y didnt you use curly braces in case &lt;strong&gt;a&lt;/strong&gt;...you have just opened only for &lt;strong&gt;b&lt;/strong&gt;?</description>
		<content:encoded><![CDATA[<p>y didnt you use curly braces in case <strong>a</strong>&#8230;you have just opened only for <strong>b</strong>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: venkatrao</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-3603</link>
		<dc:creator>venkatrao</dc:creator>
		<pubDate>Thu, 21 Jul 2011 05:31:18 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-3603</guid>
		<description>excellent</description>
		<content:encoded><![CDATA[<p>excellent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yankpascal</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-3571</link>
		<dc:creator>yankpascal</dc:creator>
		<pubDate>Tue, 05 Jul 2011 19:09:50 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-3571</guid>
		<description>i like it</description>
		<content:encoded><![CDATA[<p>i like it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-1979</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Thu, 09 Dec 2010 07:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-1979</guid>
		<description>Sure you can, for example:
&lt;code&gt;
#include&lt;stdio.h&gt;

	int main()
	{
		char myinput;
                int i=5;
		printf(&quot;Which option will you choose:\n&quot;);
		printf(&quot;a) Program 1 \n&quot;);
		printf(&quot;b) Program 2 \n&quot;);
		scanf(&quot;%c&quot;, &amp;myinput);

		switch (myinput)
		{
			case &#039;a&#039;:
			 		printf(&quot;Run program 1\n&quot;);
                                        if( i == 5) {
                                                printf(&quot;OK\n&quot;);
                                        }
			 		break;
			case &#039;b&#039;:
				{
			 		printf(&quot;Run program 2\n&quot;);
					printf(&quot;Please Wait\n&quot;);
					break;
				}
			default:
					printf(&quot;Invalid choice\n&quot;);
					break;
		}
		return 0;
	}

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Sure you can, for example:<br />
<code><br />
#include&lt;stdio.h&gt;</p>
<p>	int main()<br />
	{<br />
		char myinput;<br />
                int i=5;<br />
		printf("Which option will you choose:\n");<br />
		printf("a) Program 1 \n");<br />
		printf("b) Program 2 \n");<br />
		scanf("%c", &#038;myinput);</p>
<p>		switch (myinput)<br />
		{<br />
			case 'a':<br />
			 		printf("Run program 1\n");<br />
                                        if( i == 5) {<br />
                                                printf("OK\n");<br />
                                        }<br />
			 		break;<br />
			case 'b':<br />
				{<br />
			 		printf("Run program 2\n");<br />
					printf("Please Wait\n");<br />
					break;<br />
				}<br />
			default:<br />
					printf("Invalid choice\n");<br />
					break;<br />
		}<br />
		return 0;<br />
	}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vipandeep</title>
		<link>http://www.codingunit.com/c-tutorial-the-if-and-switch-statement/comment-page-1#comment-1976</link>
		<dc:creator>Vipandeep</dc:creator>
		<pubDate>Wed, 08 Dec 2010 19:36:43 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/?p=160#comment-1976</guid>
		<description>Can we have If statement in Switch case?</description>
		<content:encoded><![CDATA[<p>Can we have If statement in Switch case?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

