La estructura selectiva permite escoger dentro de un conjunto de opciones una dentro del conjunto.
La estructura selectiva se representa en Pseudocódigo así:
Incio
DependiendoDE(Variable)
1: instruciones
2: instrucciones
" "
" "
" "
" "
En otro caso:
escribir " error "
fin DPD
fin
En Netbeans esta estructura se representa así:
Switch(desicion){
case 1: System.out.println("instruccion 1");
break;
case 2: System.out.println("instruccion 2");
break;
case 3: System.out.println("instruccion 3");
break;
" " "
" " "
" " "
default:
System.out.println("error");
}
En c++ se representa asi:
switch(opcion){
case 1:
cout<<"instruccion 1";
break;
case 2:
cout<<"instruccion 2";
break;
case 3:
cout<<"instruccion 3";
break;
default:
cout<<"error";
}
No hay comentarios.:
Publicar un comentario