int day = 4; switch (day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; case 5: Console.WriteLine("Friday"); break; case 6: Console.WriteLine...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Single-Case switch Example The example below uses a weekday number to calculate the weekday name: Example packagemain import("fmt") func main() { day :=4 switchday { case1: fmt.Println("Monday") case2: fmt.Println("Tuesday")
intday=4;switch(day){case1:System.out.println("Monday");break;case2:System.out.println("Tuesday");break;case3:System.out.println("Wednesday");break;case4:System.out.println("Thursday");break;case5:System.out.println("Friday");break;case6:System.out.println("Saturday");break;case7:Syste...
case2: day ="Tuesday"; break; case3: day ="Wednesday"; break; case4: day ="Thursday"; break; case5: day ="Friday"; break; case6: day ="Saturday"; } The result of day will be: Friday Try it Yourself » The break Keyword ...
case7: cout <<"Sunday"; break; } // Outputs "Thursday" (day 4) Try it Yourself » The break Keyword When C++ reaches abreakkeyword, it breaks out of the switch block. This will stop the execution of more code and case testing inside the block. ...