Created
May 11, 2015 17:50
-
-
Save nelson6e65/e37f6bc5eb3424e49cf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//No conozco mucho de C, pero más o menos así iría el ciclo do: | |
char l; | |
bool valida; //Definimos un variable para almacenar si la letra es válida o no (flag) | |
do { | |
printf("\nIngrese una letra: "); | |
scanf("%c", &l); | |
if (l == 's' || l == 'S' || l == 'n' || l == 'N') { | |
valida = true; | |
printf("\nLetra válida."); // Podría incluirse mejor al final del procedimiento (fuera del while), ya que no se volverá a entrar al ciclo 'do' si es válida | |
} else { | |
valida = false; | |
printf("\nLetra inválida; vuelva a intentar."); | |
} | |
} while (valida == false); //O también while(!valid); -> Sólo se repite cuando no es válida. | |
//el resto del procedimiento... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment