English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm searching the functions of switch command,to know what is its functios and to know how to use this command.

2007-02-18 19:29:17 · 3 answers · asked by mymail_ronel 1 in Computers & Internet Programming & Design

3 answers

it's used in place of multiple if-else blocks.
switch is mainly used to execute different blocks of code, depending upon a value of a variable.

for eg.
int choice;
//input choice

switch(choice)
{
case 1: printf("u input 1");
break;
case 2: printf("u input 2");
break;
default : printf("some thing else");
}

Remember to give a break statement after each case, otherwise after one case, the other case will also be executed.

2007-02-18 19:34:00 · answer #1 · answered by orbitting_man 3 · 0 0

In nearly all the programming languages,'switch is used for multi-conditional operator.The statement analyses many statements to give one proper result.It is used for event oriented programming

2007-02-19 04:42:08 · answer #2 · answered by the dreamfinder 2 · 0 0

switch is not a command, it's key word.

See the previous answer for details on how to use it.

2007-02-19 03:45:09 · answer #3 · answered by kvasani 2 · 0 0

fedest.com, questions and answers