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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831

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/rest-api/class-wp-rest-server.php on line 1831
{"id":27465,"date":"2015-11-24T22:53:44","date_gmt":"2015-11-25T04:53:44","guid":{"rendered":"http:\/\/myfreakingcrazythoughts.wordpress.com\/?p=268"},"modified":"2015-11-24T22:53:44","modified_gmt":"2015-11-25T04:53:44","slug":"use-of-switch-as-a-conditional-3","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2015\/2015\/use-of-switch-as-a-conditional-3\/","title":{"rendered":"Use of \u201cSwitch\u201d as a Conditional."},"content":{"rendered":"

The syntax of the switch statement is a bit peculiar. Its purpose is to check for a value among a number of possible constant expressions. It is something similar to concatenating if-else statements, but limited to constant expressions. Its most typical syntax is:<\/p>\n

\n
switch<\/span> (<\/span>expression<\/span>)<\/span>\n{<\/span>\n  case<\/span> constant1<\/span>:\n     group<\/span>-<\/span>of<\/span>-<\/span>statements<\/span>-<\/span>1<\/span>;<\/span>\n     break<\/span>;<\/span>\n  case<\/span> constant2<\/span>:\n     group<\/span>-<\/span>of<\/span>-<\/span>statements<\/span>-<\/span>2<\/span>;<\/span>\n     break<\/span>;<\/span>\n  .<\/span>\n  .<\/span>\n  .<\/span>\n  default:<\/span>\n     default<\/span>-<\/span>group<\/span>-<\/span>of<\/span>-<\/span>statements<\/span>\n}<\/span>\n<\/pre>\n<\/div>\n

 <\/p>\n

Basically, what \u201cSwitch\u201d actually does is to evaluate expression <\/em>and checks if it is equivalent to constant1; <\/em>if it is, it executes group-of-statements-1 until it finds the break statement. When it finds this break statement, the program jumps to the end of the entire switch statement (the closing brace).<\/p>\n

If expression was not equal to constant1, it is then checked against constant2. If it is equal to this, it executes group-of-statements-2 until a break is found, when it jumps to the end of the switch. Finally, if the value of expression did not match any of the previously specified constants (there may be any number of these), the program executes the statements included after the default: label, if it exists (since it is optional). Both of the following code fragments have the same behavior, demonstrating the if-else equivalent of a switch statement:<\/p>\n\n\n\n\n
switch example<\/strong><\/td>\nif-else equivalent<\/strong><\/td>\n<\/tr>\n
<\/p>\n
\n
switch<\/span> (<\/span>x<\/span>)<\/span> {<\/span>\n\n  case<\/span> 1<\/span>:\n\n    cout<\/span> <<<\/span> \"x is 1\"<\/span>;<\/span>\n\n    break<\/span>;<\/span>\n\n  case<\/span> 2<\/span>:\n\n    cout<\/span> <<<\/span> \"x is 2\"<\/span>;<\/span>\n\n    break<\/span>;<\/span>\n\n  default:<\/span>\n\n    cout<\/span> <<<\/span> \"value of x unknown\"<\/span>;<\/span>\n\n  }<\/span>\n<\/pre>\n<\/div>\n<\/td>\n
<\/p>\n
\n
if<\/span> (<\/span>x<\/span> ==<\/span> 1<\/span>)<\/span> {<\/span>\n\ncout<\/span> &<\/span>lt<\/span>;<\/span>&<\/span>lt<\/span>;<\/span> \"x is 1\"<\/span>;<\/span>\n\n}<\/span>\n\nelse<\/span> if<\/span> (<\/span>x<\/span> ==<\/span> 2<\/span>)<\/span> {<\/span>\n\ncout<\/span> &<\/span>lt<\/span>;<\/span>&<\/span>lt<\/span>;<\/span> \"x is 2\"<\/span>;<\/span>\n\n}<\/span>\n\nelse<\/span> {<\/span>\n\ncout<\/span> &<\/span>lt<\/span>;<\/span>&<\/span>lt<\/span>;<\/span> \"value of x unknown\"<\/span>;<\/span>\n\n}<\/span>\n<\/pre>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

 <\/p>\n

Here is a simple example of a code with a \u201cSwitch\u201d Statement in it.<\/p>\n

\n
switch<\/span> (<\/span>x<\/span>)<\/span> {<\/span>\n  case<\/span> 1<\/span>:\n  case<\/span> 2<\/span>:\n  case<\/span> 3<\/span>:\n    cout<\/span> <<<\/span> \"x is 1, 2 or 3\"<\/span>;<\/span>\n    break<\/span>;<\/span>\n  default:<\/span>\n    cout<\/span> <<<\/span> \"x is not 1, 2 nor 3\"<\/span>;<\/span>\n  }<\/span>\n<\/pre>\n<\/div>\n

 <\/p>\n

Sources:<\/p>\n

http:\/\/en.cppreference.com\/w\/cpp\/language\/switch<\/a><\/p>\n

http:\/\/www.cplusplus.com\/doc\/tutorial\/control\/#switch<\/a><\/p>\n

-The Admin.<\/p>\n

\"\"<\/a> \"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

The syntax of the switch statement is a bit peculiar. Its purpose is to check for a value among a number of possible constant expressions. It is something similar to concatenating if-else statements, but limited to constant expressions. Its most… Continue Reading →<\/a>\"\"<\/p>\n","protected":false},"author":259,"featured_media":27464,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[582,206,62,887,617,614,615],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27465"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/users\/259"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=27465"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27465\/revisions"}],"predecessor-version":[{"id":27466,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27465\/revisions\/27466"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media\/27464"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=27465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=27465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=27465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}