Hello this is #Mastery17<\/a> that talks about using switch as a conditional. A switch sentence makes a variable to be tested to be equal against some values. Every value is named a case and the value is checked for every case.<\/span><\/p>\n \u00a0<\/span><\/p>\n The structure of a switch is\u2026<\/span><\/p>\n \u00a0<\/span><\/p>\n Switch (the expression)<\/span><\/p>\n \u00a0\u00a0\u00a0 <\/span><\/span><\/p>\n Case and constant expression: statement<\/span><\/p>\n \u00a0<\/span><\/p>\n [default : statement ]<\/span><\/p>\n \u00a0<\/span><\/sub><\/p>\n When you make a switch statement make sure you are aware of:<\/span><\/p>\n –\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span>It is easier for the switch expression to work if it is an integer or an enumerated type.<\/span><\/p>\n –\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span>The number of cases is unlimited, each one has to be separated with the value they are compared to with a : .<\/span><\/p>\n –\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span>The constant and the expression compared have to be the same type.<\/span><\/p>\n –\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span>When a variable is equal to a case, the statements net to that case will execute until a break statement appears.<\/span><\/p>\n –\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span>A break the switch ends and the control jumps to the following line of the switch.<\/span><\/p>\n \u00a0<\/span><\/p>\n \u00a0<\/span><\/p>\n I found this diagram on <\/a>http:\/ <\/span><\/p>\n The behavior of a switch statement goes like this:<\/span><\/p>\n \u00a0<\/span><\/p>\n If s converted value matches the expression \u2013 Control is transferred to a statement following the label.<\/span><\/p>\n \u00a0<\/span><\/p>\n If none of the constants match the ones on the case \u2013 Control is transferred to a default label.<\/span><\/p>\n \u00a0<\/span><\/p>\n <\/p>\n If none of the constants match the constants in the case labels \u2013 Control is transferred to the statement after the switch statement.<\/span><\/p>\n \u00a0<\/p>\n I created this simple program as an example for the usage of a switch conditional. It evaluates the number introduced and says if you are an adult or not.<\/span><\/p>\n \u00a0<\/p>\n <\/span><\/p>\n <\/span><\/p>\n <\/span><\/p>\n Hello this is #Mastery17<\/a> that talks about using switch as a conditional. A switch sentence makes a variable to be tested to be equal against some values. Every value is named a case and the value is checked for every case.<\/span><\/p>\n <\/span><\/p>\n The structure of a switch is…<\/span><\/p>\n <\/span><\/p>\n Switch (the expression)<\/span><\/p>\n <\/span><\/span><\/p>\n Case and constant expression: statement<\/span><\/p>\n <\/span><\/p>\n [default : statement ]<\/span><\/p>\n <\/span><\/sub><\/p>\n When you make a switch statement make sure you are aware of:<\/span><\/p>\n – <\/span><\/span><\/span>It is easier for the switch expression to work if it is an integer or an enumerated type.<\/span><\/p>\n – <\/span><\/span><\/span>The number of cases is unlimited, each one has to be separated with the value they are compared to with a : .<\/span><\/p>\n – <\/span><\/span><\/span>The constant and the expression compared have to be the same type.<\/span><\/p>\n – <\/span><\/span><\/span>When a variable is equal to a case, the statements net to that case will execute until a break statement appears.<\/span><\/p>\n – <\/span><\/span><\/span>A break the switch ends and the control jumps to the following line of the switch.<\/span><\/p>\n <\/span><\/p>\n <\/span><\/p>\n I found this diagram on <\/a>http:\/\/www.tutorialspoint.com\/cplusplus\/images\/cpp_switch_statement.jpg<\/a> that may explain better this process.<\/span><\/p>\n <\/span><\/p>\n The behavior of a switch statement goes like this:<\/span><\/p>\n <\/span><\/p>\n If s converted value matches the expression – Control is transferred to a statement following the label.<\/span><\/p>\n <\/span><\/p>\n If none of the constants match the ones on the case – Control is transferred to a default label.<\/span><\/p>\n <\/span><\/p>\n <\/p>\n 96<\/p>\n <\/p>\n Normal 21<\/p>\n false ES-TRAD <\/p>\n <\/p>\n \/* Style Definitions *\/ <\/p>\n If none of the constants match the constants in the case labels – Control is transferred to the statement after the switch statement.<\/span><\/p>\n <\/p>\n I created this simple program as an example for the usage of a switch conditional. It evaluates the number introduced and says if you are an adult or not.<\/span><\/p>\n <\/p>\n <\/span><\/p>\n <\/span><\/p>\n <\/span><\/p>\nWATCH MY VIDEO\u00a0https:\/
\u00a0<\/h2>\n<\/div>\n","protected":false},"excerpt":{"rendered":"
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\ntable.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin:0cm;
\n\tmso-para-margin-bottom:.0001pt;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:12.0pt;
\n\tfont-family:Calibri;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\nWATCH MY VIDEO https:\/\/youtu.be\/-_8H_XSRJR8<\/a><\/span><\/h1>\n
<\/h2>\n<\/div>\n","protected":false},"author":254,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[186,116],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/26718"}],"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\/254"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=26718"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/26718\/revisions"}],"predecessor-version":[{"id":30001,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/26718\/revisions\/30001"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=26718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=26718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=26718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}