Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘#Switch’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Wed, 25 Nov 2015 03:24:08 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Mastery 17 https://kenscourses.com/tc101fall2015/2015/mastery-17-10/ Wed, 25 Nov 2015 03:24:08 +0000 http://opezaimd.tumblr.com/post/133904163660 On this mastery I’ll show you what and how to use the conditional switch in C++.

Switch is a statement that tests a variable for equality in a list of given conditions. It is somehow a summarized version of IF when you have a lot of conditions. 

This flow chart may help you understand better, and this webpage too:

The default syntax of switch goes like this:

switch (expression)
case “condition” : outcome
[default:statement]    //This is used when the variable input isn’t a valid option.

So, for the purpose of this mastery, lets create a program were the user can input his points on masteries so far and tell him if his good or screwed. Do as follows:

  1. Create our “basic” program.
  2. Inside the int, declare a char variable with an assigned value.
  3. Use switch to condition the outcome and tell the user if his good or screwed.

Your program should look something like this:

Now let’s test it:

Let’s just play with another value:

Great! Now you know what and how to use switch conditional.

]]>
On this mastery I’ll show you what and how to use the conditional switch in C++.

Switch is a statement that tests a variable for equality in a list of given conditions. It is somehow a summarized version of IF when you have a lot of conditions. 

This flow chart may help you understand better, and this webpage too:

The default syntax of switch goes like this:

switch (expression)
case “condition” : outcome
[default:statement]    //This is used when the variable input isn’t a valid option.

So, for the purpose of this mastery, lets create a program were the user can input his points on masteries so far and tell him if his good or screwed. Do as follows:

  1. Create our “basic” program.
  2. Inside the int, declare a char variable with an assigned value.
  3. Use switch to condition the outcome and tell the user if his good or screwed.

Your program should look something like this:

Now let’s test it:

Let’s just play with another value:

Great! Now you know what and how to use switch conditional.

]]>
https://creativecommons.org/licenses/by/4.0/