Octave is open-source, free available for many of the platforms. It is a high-level language. It comes up with a text interface along with an experimental graphical interface. It is also used for various Machine Learning algorithms for solving various numeric problems. You can say that it is similar to MATLAB but slower than MATLAB.

Switch case statements are a substitute for long if statements that compare a variable to several integral values. Switch case in Octave is a multiway branch statement. It allows a variable to be tested for equality against a list of values.

Switch statement follows the approach of mapping and searching over a list of values. If there is more than one match for a specific value, then the switch statement will return the first match found of the value matched with the expression.

**Flowchart :**

**Syntax :**

switch (expression) case label command_list case label command_list ... otherwise command_list endswitch

**Examples:**

`% value of choice ` `choice = 3; ` ` ` `switch` `choice ` ` ` `case` `1 ` ` ` `printf(` `"Choice is 1\n"` `); ` ` ` `case` `2 ` ` ` `printf(` `"Choice is 2\n"` `); ` ` ` `case` `3 ` ` ` `printf(` `"Choice is 3\n"` `); ` ` ` `otherwise` ` ` `printf(` `"Choice is other than 1, 2, 3\n"` `); ` `endswitch ` |

*chevron_right*

*filter_none*

**Output :**

Choice is 3

## Recommended Posts:

- How to take input in Octave GNU?
- Comments in Octave GNU
- How to output in Octave GNU
- Vectors in Octave GNU
- Strings in Octave GNU
- Basic Operations in Octave
- How to load and modify matrices and vectors in Octave?
- How to Perform Computational Operations in Octave?
- Loops (For and While) and Control Statements in Octave
- Octave - Basics of Plotting Data
- Difference Between MATLAB and Octave
- Where Statement in SAS Programming
- If-Then-Else statement in SAS Programming
- Case conversion of a String in R Language - toupper(), tolower(), casefold() and cartr() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.